diff options
author | Simon Howard | 2014-10-18 20:33:30 -0400 |
---|---|---|
committer | Simon Howard | 2014-10-18 20:33:30 -0400 |
commit | 5914e16076339ef487094dba8be67eed21b0a811 (patch) | |
tree | 36c72e60e176f495bd391dfc6da09cbbb60e4acc /src/heretic | |
parent | 2ab317c4b7c304bc624f803e7b5763ab27f39f7b (diff) | |
download | chocolate-doom-5914e16076339ef487094dba8be67eed21b0a811.tar.gz chocolate-doom-5914e16076339ef487094dba8be67eed21b0a811.tar.bz2 chocolate-doom-5914e16076339ef487094dba8be67eed21b0a811.zip |
dehacked: Allow override of string replacements.
If loading two dehacked patches and both replace the same string,
the second replacement should override the first. Change the API
function DEH_AddStringReplacement so that the from_text and to_text
are implicitly duplicated, and we can free to_text and replace
it later if we subsequently change it to something else.
Diffstat (limited to 'src/heretic')
-rw-r--r-- | src/heretic/deh_htext.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/heretic/deh_htext.c b/src/heretic/deh_htext.c index 55f32872..fe0dc663 100644 --- a/src/heretic/deh_htext.c +++ b/src/heretic/deh_htext.c @@ -16,6 +16,7 @@ // #include <stdio.h> +#include <stdlib.h> #include <string.h> #include "doomtype.h" @@ -776,7 +777,7 @@ static void *DEH_TextStart(deh_context_t *context, char *line) return NULL; } - repl_text = Z_Malloc(repl_len + 1, PU_STATIC, NULL); + repl_text = malloc(repl_len + 1); // read in the "to" text @@ -819,13 +820,10 @@ static void *DEH_TextStart(deh_context_t *context, char *line) // Success. DEH_AddStringReplacement(orig_text, repl_text); - - return NULL; } - // Failure. - - Z_Free(repl_text); + // We must always free the replacement text. + free(repl_text); return NULL; } |