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