src/config/rcxml.c: parse xml from buffer

Avoid unit tests writing to/from files by using xmlParseMemory() instead
of xmlReadFile().
This commit is contained in:
Johan Malm 2020-06-09 21:40:46 +01:00
parent 40c0b169ef
commit bc51e0ad2f
10 changed files with 86 additions and 9 deletions

23
src/common/buf.c Normal file
View file

@ -0,0 +1,23 @@
#include "buf.h"
void buf_init(struct buf *s)
{
s->alloc = 256;
s->buf = malloc(s->alloc);
s->buf[0] = '\0';
s->len = 0;
}
void buf_add(struct buf *s, const char *data)
{
if (!data || data[0] == '\0')
return;
int len = strlen(data);
if (s->alloc <= s->len + len + 1) {
s->alloc = s->alloc + len;
s->buf = realloc(s->buf, s->alloc);
}
memcpy(s->buf + s->len, data, len);
s->len += len;
s->buf[s->len] = 0;
}

3
src/common/meson.build Normal file
View file

@ -0,0 +1,3 @@
labwc_sources += files(
'buf.c',
)