damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 371e9fb4065a9e23f16868cd61eab19c435673de
parent aa5809d79204f0a105cc8217520cf715b7e8df37
Author: William Casarin <jb55@jb55.com>
Date:   Wed, 27 Dec 2023 12:40:26 -0800

nostrdb/cursor: add malloc_slice

This is the same as cursor_slice except we don't memset afterwards

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Mnostrdb/src/cursor.h | 10++++++++++
1 file changed, 10 insertions(+), 0 deletions(-)

diff --git 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) {