#define max(x, y) ( (x) > (y) ? (x) : (y) ) typedef struct tagString {    char *Buffer;    unsigned int Length;    unsigned int Size; } String; String *str_create(const char *str) {    String *retval = (String *)malloc(sizeof(String));    memset(retval, 0, sizeof(String));    if(str != NULL) {        retval->Length = strlen(str);        retval->Size = max(retval->Length + 1, 64);        retval->Buffer = (char *)malloc(retval->Size);        strncpy(retval->Buffer, str, retval->Size);    }    return retval; } String *str_destroy(String *str) {    if(str != NULL) {        if(str->Buffer != NULL) free(str->Buffer);        free(str);    }    return NULL; } String *str_concate(String *str, const char *buffer) {    if(str != NULL && str->Buffer != NULL && buffer != NULL) {        int len = strlen(buffer);        if(str->Length + len >= str->Size) {           str->Size += max(len + 1, 64);           str->Buffer = (char *)realloc(str->Buffer, str->Size);        }        strncat(str->Buffer, buffer, str->Size);    }    return str; } typedef struct tagStringVector {   String **Array;   unsigned int Length;   unsigned int Size; } StringVector; StringVector *strvec_create() {   StringVector *retval = (StringVector *)malloc(sizeof(StringVector));   memset(retval, 0, sizeof(StringVector));   return retval; } StringVector *strvec_destroy(StringVector *strvec) {   if(strvec != NULL) {      unsigned int i;      for(i = 0; i < strvec->Length; ++i) {         strvec->Array[i] = str_destroy(strvec->Array[i]);      }      if(strvec->Array != NULL) free(strvec->Array);      free(strvec);   }   return NULL; } void strvec_push(StringVector *strvec, const char *buffer) {    String *str = str_create(buffer);    if(strvec->Length >= strvec->Size) {        strvec->Size += 8;        if(strvec->Array == NULL)            strvec->Array = (String **)malloc(                strvec->Size * sizeof(String *)            );        else            strvec->Array = (String **)realloc(                strvec->Array,                strvec->Size * sizeof(String *)            );    }    strvec->Array[strvec->Length++] = str; } String *strvec_str_at(StringVector *strvec, unsigned int idx) {    if(strvec && strvec->Length > idx)        return strvec->Array[idx];    else        return NULL; } const char *strvec_ptr_at(StringVector *strvec, unsigned int idx) {    String *str = strvec_str_at(strvec, idx);    if(str != NULL)        return str->Buffer;    else        return NULL; }