diff --git a/src/main.c b/src/main.c index 2d77d07..fbf91a6 100644 --- a/src/main.c +++ b/src/main.c @@ -282,6 +282,11 @@ int main (int argc, char **argv) if(buffer) free(buffer); + cucul_free_buffer(input_buffer); + cucul_free_buffer(output_buffer); + cucul_free_canvas(canvas); + + return 0; } @@ -510,15 +515,16 @@ char *replace(char *str, char *oldpiece, const char *newpiece) new_len, old_len, cpy_len; char *c = NULL; char *newstr = NULL; + char *orig = str; if(oldpiece==NULL || newpiece==NULL) return NULL; - if ((c = (char *) strstr(str, oldpiece)) == NULL) { + if ((c = (char *) strstr(str, oldpiece)) == NULL) return str; - } - newstr = malloc(1024); + + newstr = malloc(8192); // FIXME if(newstr == NULL) { @@ -552,6 +558,7 @@ char *replace(char *str, char *oldpiece, const char *newpiece) /* Copy remaining characters from the right of last matched pattern */ strcpy(newstr+newstr_index, str+str_index); + str = orig; return newstr; }