summaryrefslogtreecommitdiffstats
path: root/strlist.c
blob: c802285923e69dc4aab0a02a170665f35dc3f507 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// SPDX-FileCopyrightText: 2018 Tomasz Kramkowski <tomasz@kramkow.ski>
// SPDX-License-Identifier: CC0-1.0
#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;
}