Add uc_str_append_all function

This commit is contained in:
Nils O. Selåsdal
2013-09-15 00:01:19 +02:00
parent 03d700595b
commit 9988d8f4c0
3 changed files with 88 additions and 0 deletions
+25
View File
@@ -105,3 +105,28 @@ void uc_strv_destroy(struct UCStrv *strv)
strv->strings = NULL;
}
int uc_strv_append_all(struct UCStrv *a, struct UCStrv *b, int copy)
{
size_t i;
int rc;
rc = uc_strv_grow(a, a->allocated + b->cnt);
if (rc != 0) {
return rc;
}
for (i = 0; i < b->cnt; i++) {
if (copy) {
rc = uc_strv_append(a, b->strings[i]);
} else {
rc = uc_strv_append_nocopy(a, b->strings[i]);
}
if (rc != 0) {
return rc;
}
}
return 0;
}