vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 990a85e48e872e2c421d38961d3033024893c44e
parent a114c4be0d67986adedde955ff44edc85449152b
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Tue, 20 Dec 2016 19:10:58 +0100

buffer: implement buffer_capacity utility function

Diffstat:
Mbuffer.c | 4++++
Mbuffer.h | 2++
2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/buffer.c b/buffer.c @@ -153,6 +153,10 @@ size_t buffer_length(Buffer *buf) { return buf->len; } +size_t buffer_capacity(Buffer *buf) { + return buf->size; +} + const char *buffer_content(Buffer *buf) { return buf->data; } diff --git a/buffer.h b/buffer.h @@ -50,6 +50,8 @@ bool buffer_appendf(Buffer*, const char *fmt, ...); size_t buffer_length0(Buffer*); /* return length of a buffer including possible NUL byte */ size_t buffer_length(Buffer*); +/* return current maximal capacity in bytes of this buffer */ +size_t buffer_capacity(Buffer*); /* pointer to buffer data, guaranteed to return a NUL terminated * string even if buffer is empty */ const char *buffer_content0(Buffer*);