-/*********************************************************************
- *
- * Function : strsav
- *
- * Description : Reallocate "old" and append text to it. This makes
- * it easier to append to malloc'd strings.
- *
- * Parameters :
- * 1 : old = Old text that is to be extended. Will be
- * free()d by this routine.
- * 2 : text_to_append = Text to be appended to old.
- *
- * Returns : Pointer to newly malloc'ed appended string.
- * If there is no text to append, return old. Caller
- * must free().
- *
- *********************************************************************/
-char *strsav(char *old, const char *text_to_append)
-{
- int old_len, new_len;
- char *p;
-
- if (( text_to_append == NULL) || (*text_to_append == '\0'))
- {
- return(old);
- }
-
- if (NULL != old)
- {
- old_len = strlen(old);
- }
- else
- {
- old_len = 0;
- }
-
- new_len = old_len + strlen(text_to_append) + 1;
-
- if (old)
- {
- if ((p = realloc(old, new_len)) == NULL)
- {
- log_error(LOG_LEVEL_FATAL, "realloc(%d) bytes for proxy_args failed!", new_len);
- /* Never get here - LOG_LEVEL_FATAL causes program exit */
- }
- }
- else
- {
- if ((p = (char *)malloc(new_len)) == NULL)
- {
- log_error(LOG_LEVEL_FATAL, "malloc(%d) bytes for proxy_args failed!", new_len);
- /* Never get here - LOG_LEVEL_FATAL causes program exit */
- }
- }
-
- strcpy(p + old_len, text_to_append);
- return(p);
-
-}
-