From c55956b6a10d0a4d0b151c1be976dc9c344c1103 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Sun, 14 Dec 2014 20:38:14 +0200 Subject: More fixes to stop allocating an extra byte. --- builtin.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'builtin.c') diff --git a/builtin.c b/builtin.c index 838ab899..067b410e 100644 --- a/builtin.c +++ b/builtin.c @@ -2554,7 +2554,7 @@ do_match(int nargs) sprintf(buff, "%d", ii); ilen = strlen(buff); - amt = ilen + subseplen + strlen("length") + 2; + amt = ilen + subseplen + strlen("length") + 1; if (oldamt == 0) { emalloc(buf, char *, amt, "do_match"); @@ -2876,9 +2876,8 @@ set_how_many: /* guesstimate how much room to allocate; +2 forces > 0 */ buflen = textlen + (ampersands + 1) * repllen + 2; - emalloc(buf, char *, buflen + 2, "do_sub"); + emalloc(buf, char *, buflen + 1, "do_sub"); buf[buflen] = '\0'; - buf[buflen + 1] = '\0'; bp = buf; for (current = 1;; current++) { @@ -3006,7 +3005,7 @@ set_how_many: } sofar = bp - buf; if (buflen - sofar - textlen - 1) { - buflen = sofar + textlen + 2; + buflen = sofar + textlen + 1; erealloc(buf, char *, buflen, "do_sub"); bp = buf + sofar; } -- cgit v1.2.3