summaryrefslogtreecommitdiffstats
path: root/strlist.c
diff options
context:
space:
mode:
Diffstat (limited to 'strlist.c')
-rw-r--r--strlist.c24
1 files changed, 24 insertions, 0 deletions
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 <assert.h>
+#include <stdlib.h>
+#include <string.h>
+
+#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;
+}