|
|
@@ -458,7 +458,7 @@ char *replace(char *s1, char *oldpiece, const char *newpiece) |
|
|
|
tocopy = strlen(s1 + i1); |
|
|
|
if(oldlen < newlen) |
|
|
|
s2 = realloc(s2, i2 + tocopy + 1); |
|
|
|
memmove(s2 + i2, s1 + i1, tocopy + 1); |
|
|
|
memcpy(s2 + i2, s1 + i1, tocopy + 1); |
|
|
|
if(oldlen < newlen) |
|
|
|
free(s1); |
|
|
|
return s2; |
|
|
@@ -468,7 +468,7 @@ char *replace(char *s1, char *oldpiece, const char *newpiece) |
|
|
|
if(oldlen < newlen) |
|
|
|
s2 = realloc(s2, i2 + tocopy + newlen); |
|
|
|
memmove(s2 + i2, s1 + i1, tocopy); |
|
|
|
memcpy(s2 + tocopy, newpiece, newlen); |
|
|
|
memcpy(s2 + i2 + tocopy, newpiece, newlen); |
|
|
|
i1 += tocopy + oldlen; |
|
|
|
i2 += tocopy + newlen; |
|
|
|
} |
|
|
|