From 371e9fb4065a9e23f16868cd61eab19c435673de Mon Sep 17 00:00:00 2001 From: William Casarin Date: Wed, 27 Dec 2023 12:40:26 -0800 Subject: [PATCH] nostrdb/cursor: add malloc_slice This is the same as cursor_slice except we don't memset afterwards Signed-off-by: William Casarin --- nostrdb/src/cursor.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/nostrdb/src/cursor.h b/nostrdb/src/cursor.h index 028f3993..92781743 100644 --- a/nostrdb/src/cursor.h +++ b/nostrdb/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) {