nostrdb

an unfairly fast embedded nostr database backed by lmdb
git clone git://jb55.com/nostrdb
Log | Files | Refs | Submodules | README | LICENSE

commit bf8f2a8d2808c843ae2a0137687f5d7e054d2346
parent 9152e0c149144ad8b73fa4e91b5d31c690e9b43c
Author: William Casarin <jb55@jb55.com>
Date:   Tue, 21 Nov 2023 15:41:16 -0800

cursor: add cursor_skip

this is useful for skipping over data safely

Diffstat:
Mcursor.h | 10++++++++++
1 file changed, 10 insertions(+), 0 deletions(-)

diff --git a/cursor.h b/cursor.h @@ -74,6 +74,16 @@ static inline void *cursor_malloc(struct cursor *mem, unsigned long size) return ret; } +static inline int cursor_skip(struct cursor *cursor, int n) +{ + if (cursor->p + n >= cursor->end) + return 0; + + cursor->p += n; + + return 1; +} + static inline int cursor_slice(struct cursor *mem, struct cursor *slice, size_t size) { unsigned char *p;