Skip to content

Conversation

@andreymuch
Copy link

Реализовал функцию stringFormat

TString result;
result.size = size;
result.capacity = size + 1;
result.data = (char*)malloc(result.capacity);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
result.data = (char*)malloc(result.capacity);
result.data = (char*)malloc(result.capacity * sizeof(char));

va_list args;
va_start(args, format);
va_list args_copy;
va_copy(args_copy, args);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to do it without a copy?

return res;
}

TString stringFormat(const char* format, ...) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the function definition somewhere at the beginning next to the rest
And add some tests for your function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants