diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2021-01-17 23:13:47 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2021-01-17 23:13:47 -0800 |
| commit | eb79c4a806f589badfca32e312a31ccef50ab0d7 (patch) | |
| tree | 7ef4daf367a62160d690f15e224173611b4ee78d /pattern.c | |
| parent | ffdf32da2f20d21d5adee1231e3ac8207edab78d (diff) | |
No longer allocatte memory for replacement string
Diffstat (limited to 'pattern.c')
| -rw-r--r-- | pattern.c | 12 |
1 files changed, 2 insertions, 10 deletions
@@ -103,15 +103,11 @@ static pat_t *expand_choices(file_t *f, pat_t *first) if (!matchchar(&str, quote)) file_err(f, &repstr[-1], str, "This string doesn't have a closing quote."); - size_t replace_len = (size_t)(str-repstr-1); - const char *replacement = xcalloc(sizeof(char), replace_len+1); - memcpy((void*)replacement, repstr, replace_len); - pat_t *replacepat = first; first = new_pat(f, replacepat->start, BP_REPLACE); first->args.replace.pat = replacepat; - first->args.replace.text = replacement; - first->args.replace.len = replace_len; + first->args.replace.text = repstr; + first->args.replace.len = (size_t)(str-repstr-1); first->len = replacepat->len; first->end = str; } @@ -620,10 +616,6 @@ void destroy_pat(pat_t *pat) if (pat->args.capture.name) xfree(&pat->args.capture.name); break; - case BP_REPLACE: - if (pat->args.replace.text) - xfree(&pat->args.replace.text); - break; default: break; } } |
