diff options
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | builtin.c | 7 |
2 files changed, 15 insertions, 5 deletions
@@ -1,3 +1,16 @@ +2019-08-15 Arnold D. Robbins <arnold@skeeve.com> + + Revert a6df7afc605079df7d85318846a522ef64aaa44d, change of + 2016-05-03, which used realloc to shrink the buffer, in an + attempt to save memory. In actuality, it could cause increased + memory usage, even though there was no memory leak. See + https://lists.gnu.org/archive/html/bug-gawk/2019-08/msg00003.html + and the rest of thread for more detail. + + * builtin.c (format_tree): Don't use realloc, just call + make_str_node with the original buffer. Remove `olen_final' + variable and its use. + 2019-08-15 Andrew J. Schorr <aschorr@telemetry-investments.com> Reduce memory usage by only compiling the IGNORECASE version of @@ -685,7 +685,7 @@ format_tree( int i, nc; bool toofew = false; char *obuf, *obufout; - size_t osiz, ofre, olen_final; + size_t osiz, ofre; const char *chbuf; const char *s0, *s1; int cs1; @@ -1646,10 +1646,7 @@ mpf1: _("too many arguments supplied for format string")); } bchunk(s0, s1 - s0); - olen_final = obufout - obuf; - if (ofre > 0) - erealloc(obuf, char *, olen_final + 1, "format_tree"); - r = make_str_node(obuf, olen_final, ALREADY_MALLOCED); + r = make_str_node(obuf, obufout - obuf, ALREADY_MALLOCED); obuf = NULL; out: { |