diff options
author | June McEnroe <june@causal.agency> | 2018-11-21 17:46:47 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2018-11-21 17:47:42 -0500 |
commit | a3ce3fbc08f5d5bad9c069b27f7bb49f455bc9d1 (patch) | |
tree | c3ef7269279601c10f6e6912e032857e0c7ea91f | |
parent | Track hot slice in tables (diff) | |
download | src-a3ce3fbc08f5d5bad9c069b27f7bb49f455bc9d1.tar.gz src-a3ce3fbc08f5d5bad9c069b27f7bb49f455bc9d1.zip |
Free buffer block if empty when allocating new block
-rw-r--r-- | bin/edi/buffer.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/bin/edi/buffer.c b/bin/edi/buffer.c index 62f55bee..86575ad3 100644 --- a/bin/edi/buffer.c +++ b/bin/edi/buffer.c @@ -74,6 +74,10 @@ void bufferDelete(struct Buffer *buf) { wchar_t *bufferDest(struct Buffer *buf, size_t len) { if (buf->len + len > buf->cap) { + if (!buf->len) { + buf->block = buf->block->prev; + free(buf->block); + } while (len > buf->cap) buf->cap *= 2; buf->block = blockAlloc(buf->block, buf->cap); buf->len = 0; |