Skip to content

Commit

Permalink
remove medium buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
sulincix committed May 26, 2024
1 parent 990d1d6 commit b7cdaf6
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/ccode/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,16 +217,26 @@ int startswith(const char* data, const char* f) {
}


char medium_buffer[1024*1024];
char* build_string(char* format, ...){
strcpy(medium_buffer,"");
char* build_string(char* format, ...) {
va_list args;
va_start (args, format);
vsprintf (medium_buffer, format, args);
va_end (args);
return medium_buffer;
va_start(args, format);

}
/* Determine the size needed for the string */
int size = vsnprintf(NULL, 0, format, args) + 1;
va_end(args);

/* Allocate memory for the string */
char* result = (char*)malloc(size);
if (result == NULL) {
return "";
}

/* Format the string */
va_start(args, format);
vsnprintf(result, size, format, args);
va_end(args);

return result;
}

#endif

0 comments on commit b7cdaf6

Please sign in to comment.