summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-06-17 07:28:15 -0700
committerKaz Kylheku <kaz@kylheku.com>2019-06-17 07:28:15 -0700
commit0875f85d8bb6cf61b6a9ed612936712d5fd0f66a (patch)
tree4e29634f339c554be2cb8f66d189df71bfb5af01
parentd9852ccd9cdfbffb3e4e2ec0c4c8031ce7edc4f8 (diff)
downloadtxr-0875f85d8bb6cf61b6a9ed612936712d5fd0f66a.tar.gz
txr-0875f85d8bb6cf61b6a9ed612936712d5fd0f66a.tar.bz2
txr-0875f85d8bb6cf61b6a9ed612936712d5fd0f66a.zip
buffers: comment added in buf_shrink.
* buf.c (buf_shrink): It's not immediately obvious why len is incremented by one if it is zero.
-rw-r--r--buf.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/buf.c b/buf.c
index 910d7801..ce196976 100644
--- a/buf.c
+++ b/buf.c
@@ -175,7 +175,7 @@ static void buf_shrink(struct buf *b)
val len = b->len;
if (len == zero)
- len = succ(len);
+ len = succ(len); /* avoid reallocing to zero length; i.e. freeing */
if (len != b->size) {
b->data = chk_realloc(b->data, c_num(len));