12 Jan
2008
12 Jan
'08
9:16 a.m.
On Sat, 2008-01-12 at 15:05 +0100, reimar wrote:
+void stringset_free(stringset_t *set) { + free(*set); + *set = NULL; +} + +void stringset_add(stringset_t *set, const char *str) { + int count = 0; + while ((*set)[count]) count++; + count++; + *set = realloc(*set, sizeof(char *) * (count + 1)); + (*set)[count - 1] = strdup(str); + (*set)[count] = NULL; +}
Is there a need to strdup() the strings? The memory now allocated by strdup is not freed anywhere.