From: Paul O. <po...@ne...> - 2012-07-03 13:29:55
|
Each time the string_list_add method resizes the string_list, it fails to add the passed in value to the list. See attachment that fixes it. Below is old/new source code for quick reference. --------------old int string_list_add(string_list *a, char *value) { if (a->count >= (a->size - 2)) { char **new; a->size += 8; new = realloc(a->values, a->size * sizeof(char **)); if (new != NULL) { a->values = new; return a->size; } return 0; } if ((a->values[a->count] = strdup(value)) == NULL) return 0; a->count++; return 1; } -------------------- ----------------patched int string_list_add(string_list *a, char *value) { if (a->count >= (a->size - 2)) { char **new; a->size += 8; new = realloc(a->values, a->size * sizeof(char **)); if (new != NULL) { a->values = new; } else { return 0; } } if ((a->values[a->count] = strdup(value)) == NULL) return 0; a->count++; return 1; } ------------------ Look good? -- Paul |