blob: f050f67025b40338dec9f4c93d608bb50d1da3f0 (
plain) (
tree)
|
|
#include <stdlib.h>
#include "gemtext.h"
struct gemtext **
gemtext_list_append(struct gemtext **list, struct gemtext *item)
{
int nitems;
struct gemtext **ret;
if (list != NULL) {
for (nitems = 0; list[nitems] != NULL; nitems++); /* watch out */
nitems += 2; /* one for new item, one for NULL */
} else {
nitems = 2;
}
ret = realloc(list, sizeof(*list)*nitems);
if (ret == NULL)
return NULL;
ret[nitems-2] = item;
ret[nitems-1] = NULL;
return ret;
}
|