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
commit979724dafe047e78f0c6eff50be208a11b1ec547 (patch)
tree4e29634f339c554be2cb8f66d189df71bfb5af01
parent4f32b4b14f5986447dc3b732b101916412c91d22 (diff)
downloadtxr-979724dafe047e78f0c6eff50be208a11b1ec547.tar.gz
txr-979724dafe047e78f0c6eff50be208a11b1ec547.tar.bz2
txr-979724dafe047e78f0c6eff50be208a11b1ec547.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));