utils.c
// Append a string to the string buffer
Append a string to the string buffer
Append a string to the string buffer
void append_to_string_buffer(StringBuffer *sb, char *str) {
    int len = strlen(str);
    int needed = sb->position + len;
    if (sb->allocated < needed) {
        while (sb->allocated < needed) sb->allocated <<= 1;
        sb->data = realloc(sb->data, sb->allocated);
    }
    sprintf(sb->data + sb->position, "%s", str);
    sb->position += len;
}
void append_to_string_buffer ( StringBuffer * sb , char * str ) { int len = strlen ( str ) ; int needed = sb -> position + len ; if ( sb -> allocated < needed ) { while ( sb -> allocated < needed ) sb -> allocated <<= 1 ; sb -> data = realloc ( sb -> data , sb -> allocated ) ; } sprintf ( sb -> data + sb -> position , " " , str ) ; sb -> position += len ; }
Append a string to the string buffer
Append a string to the string buffer