From f7833712f1ff318e19cb8c041f1dcef5e9488350 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 16 Aug 2017 06:38:26 -0700 Subject: buf: provide way to work with on-stack buffers. * buf.c (init_borrowed_buf): New function. (make_borrowed_buf): Reduced to wrapper around init_borrowed_buf. * buf.h (init_borrowed_buf): Declared. --- buf.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'buf.c') diff --git a/buf.c b/buf.c index 6d3f1a04..b97bef41 100644 --- a/buf.c +++ b/buf.c @@ -102,10 +102,8 @@ val bufp(val object) return tnil(type(object) == BUF); } -val make_borrowed_buf(val len, mem_t *data) +val init_borrowed_buf(obj_t *obj, val len, mem_t *data) { - val obj = make_obj(); - obj->b.type = BUF; obj->b.data = data; obj->b.len = len; @@ -114,6 +112,11 @@ val make_borrowed_buf(val len, mem_t *data) return obj; } +val make_borrowed_buf(val len, mem_t *data) +{ + return init_borrowed_buf(make_obj(), len, data); +} + val make_duplicate_buf(val len, mem_t *data) { val obj = make_obj(); -- cgit v1.2.3