diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | builtin.c | 4 |
2 files changed, 6 insertions, 2 deletions
@@ -1,5 +1,9 @@ 2016-05-03 Andrew J. Schorr <aschorr@telemetry-investments.com> + * builtin.c (format_tree): Do not waste a byte at the end of a string. + +2016-05-03 Andrew J. Schorr <aschorr@telemetry-investments.com> + * builtin.c (format_tree): After the string has been rendered, use realloc to shrink the buffer to the needed size. Otherwise, the minimum buffer size of 512 bytes can result in lots of wasted memory if many @@ -722,7 +722,7 @@ format_tree( emalloc(obuf, char *, INITIAL_OUT_SIZE, "format_tree"); obufout = obuf; osiz = INITIAL_OUT_SIZE; - ofre = osiz - 2; + ofre = osiz - 1; cur_arg = 1; @@ -1584,7 +1584,7 @@ mpf1: bchunk(s0, s1 - s0); olen_final = obufout - obuf; if (ofre > 0) - erealloc(obuf, char *, olen_final + 2, "format_tree"); + erealloc(obuf, char *, olen_final + 1, "format_tree"); r = make_str_node(obuf, olen_final, ALREADY_MALLOCED); obuf = NULL; out: |