diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2014-12-14 20:38:14 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2014-12-14 20:38:14 +0200 |
commit | c55956b6a10d0a4d0b151c1be976dc9c344c1103 (patch) | |
tree | 8711c2b5a501af116782f470fa5c0ec9e18dbabf /builtin.c | |
parent | b6ac928a53d146233741fc5f7fe1cac66de27303 (diff) | |
download | egawk-c55956b6a10d0a4d0b151c1be976dc9c344c1103.tar.gz egawk-c55956b6a10d0a4d0b151c1be976dc9c344c1103.tar.bz2 egawk-c55956b6a10d0a4d0b151c1be976dc9c344c1103.zip |
More fixes to stop allocating an extra byte.
Diffstat (limited to 'builtin.c')
-rw-r--r-- | builtin.c | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -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; } |