-static
-int append_str(char **s, const char *append)
-{
- char *old = *s;
- char *new;
- size_t oldlen = (old == NULL) ? 0 : strlen(old);
- size_t appendlen = strlen(append);
-
- new = calloc(oldlen + appendlen + 1, 1);
- if (!new) {
- return -ENOMEM;
- }
- if (oldlen) {
- strcpy(new, old);
- }
- strcat(new, append);
- *s = new;
- free(old);
- return 0;
-}
-