commit b8e5739d07674b4e2f78703b60b0ea3643187b91
parent 1565ff6b476998324ec3793de3a422acfc4d2db6
Author: Frederic Cambus <fcambus@users.sourceforge.net>
Date: Thu, 31 Dec 2015 16:34:42 +0100
Pruning now unused 'str_replace' function
Diffstat:
1 file changed, 0 insertions(+), 36 deletions(-)
diff --git a/src/ansilove.c b/src/ansilove.c
@@ -2148,42 +2148,6 @@ void alXbinLoader(char *input, char *output, char *retinaout, bool createRetinaR
gdImageDestroy(im_XBIN);
}
-// recursive string replacement
-char *str_replace(const char *string, const char *substr, const char *replacement)
-{
- char *tok = NULL;
- char *newstr = NULL;
- char *oldstr = NULL;
- char *head = NULL;
-
- // if either substr or replacement is NULL, duplicate string and let caller handle it
- if (substr == NULL || replacement == NULL) return strdup(string);
- newstr = strdup(string);
- head = newstr;
-
- while ((tok = strstr(head, substr)))
- {
- oldstr = newstr;
- newstr = malloc(strlen(oldstr) - strlen(substr) + strlen(replacement) + 1);
-
- // failed to allocate memory, free old string and return NULL
- if (newstr == NULL) {
- free (oldstr);
- return NULL;
- }
- memcpy (newstr, oldstr, tok - oldstr);
- memcpy (newstr + (tok - oldstr), replacement, strlen (replacement));
- memcpy (newstr + (tok - oldstr) + strlen(replacement),
- tok + strlen (substr), strlen (oldstr) - strlen (substr) - (tok - oldstr));
- memset (newstr + strlen (oldstr) - strlen (substr) + strlen (replacement) , 0, 1);
-
- // move back head right after the last replacement
- head = newstr + (tok - oldstr) + strlen(replacement);
- free (oldstr);
- }
- return newstr;
-}
-
// Reads SAUCE via a filename.
sauce *sauceReadFileName(char *fileName)
{