From 364eea8654a69dd0e79cdfa86c10992e6e275ccd Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Wed, 28 Feb 2018 00:35:15 +0000 Subject: init commit --- strlist.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 strlist.c (limited to 'strlist.c') diff --git a/strlist.c b/strlist.c new file mode 100644 index 0000000..58faa99 --- /dev/null +++ b/strlist.c @@ -0,0 +1,24 @@ +#include +#include +#include + +#include "eprintf.h" +#include "strlist.h" + +void sl_append(struct strlist *sl, const char **list, int count) +{ + assert(sl != NULL); + + sl->list = erealloc(sl->list, (sl->count + count) * sizeof *sl->list); + memcpy(sl->list + sl->count, list, count * sizeof *list); + sl->count += count; +} + +void sl_free(struct strlist *sl) +{ + assert(sl != NULL); + + free(sl->list); + sl->list = NULL; + sl->count = 0; +} -- cgit v1.2.3-54-g00ecf