Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify new_concat #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions SDL_FontCache.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,17 @@ static void set_color(FC_Image* src, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
static char* new_concat(const char* a, const char* b)
{
// Create new buffer
unsigned int size = strlen(a) + strlen(b);
char* new_string = (char*)malloc(size+1);
unsigned int len_a = strlen(a);
char* new_string = (char*)malloc(len_a + strlen(b) + 1);

// Concatenate strings in the new buffer
strcpy(new_string, a);
strcat(new_string, b);
strcpy(new_string + len_a, b);

return new_string;
}


static char* replace_concat(char** a, const char* b)
{
char* new_string = new_concat(*a, b);
Expand Down