commit 8ab40779e4e1895033597c00fc88ae40cd07f9b2
parent dc4795088ce1e527718bb7b56cf0d2737fb61b15
Author: William Casarin <jb55@jb55.com>
Date: Wed, 27 Dec 2023 12:40:26 -0800
cursor: add malloc_slice
This is the same as cursor_slice except we don't memset afterwards
Diffstat:
1 file changed, 10 insertions(+), 0 deletions(-)
diff --git a/src/cursor.h b/src/cursor.h
@@ -85,6 +85,16 @@ static inline int cursor_slice(struct cursor *mem, struct cursor *slice, size_t
return 1;
}
+static inline int cursor_malloc_slice(struct cursor *mem, struct cursor *slice, size_t size)
+{
+ unsigned char *p;
+ if (!(p = cursor_malloc(mem, size))) {
+ return 0;
+ }
+ make_cursor(p, mem->p, slice);
+ return 1;
+}
+
static inline void copy_cursor(struct cursor *src, struct cursor *dest)
{