cgfsng: append_null_to_list()

parent 2c48d4ad
...@@ -206,18 +206,18 @@ static void *must_alloc(size_t sz) ...@@ -206,18 +206,18 @@ static void *must_alloc(size_t sz)
return must_realloc(NULL, sz); return must_realloc(NULL, sz);
} }
/* /* Given a pointer to a null-terminated array of pointers, realloc to add one
* Given a pointer to a null-terminated array of pointers, realloc to * entry, and point the new entry to NULL. Do not fail. Return the index to the
* add one entry, and point the new entry to NULL. Do not fail. Return * second-to-last entry - that is, the one which is now available for use
* the index to the second-to-last entry - that is, the one which is * (keeping the list null-terminated).
* now available for use (keeping the list null-terminated).
*/ */
static int append_null_to_list(void ***list) static int append_null_to_list(void ***list)
{ {
int newentry = 0; int newentry = 0;
if (*list) if (*list)
for (; (*list)[newentry]; newentry++); for (; (*list)[newentry]; newentry++)
;
*list = must_realloc(*list, (newentry + 2) * sizeof(void **)); *list = must_realloc(*list, (newentry + 2) * sizeof(void **));
(*list)[newentry + 1] = NULL; (*list)[newentry + 1] = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment