damus

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

commit 56d44d0004e2d4a24ff7079631c2e79461b1fdc4
parent 7742c8fb3c76a4d2581b34338212b1c72f44e167
Author: William Casarin <jb55@jb55.com>
Date:   Mon, 19 Aug 2024 14:23:22 -0700

nostrdb: filter: allow mutable int elements

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

Diffstat:
Mnostrdb/src/nostrdb.c | 14+++++++-------
Mnostrdb/src/nostrdb.h | 2+-
2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/nostrdb/src/nostrdb.c b/nostrdb/src/nostrdb.c @@ -649,10 +649,10 @@ ndb_filter_get_string_element(const struct ndb_filter *filter, const struct ndb_ return (const char *)ndb_filter_elements_data(filter, els->elements[index]); } -uint64_t -ndb_filter_get_int_element(const struct ndb_filter_elements *els, int index) +uint64_t * +ndb_filter_get_int_element(struct ndb_filter_elements *els, int index) { - return els->elements[index]; + return &els->elements[index]; } int ndb_filter_init(struct ndb_filter *filter) @@ -4839,7 +4839,7 @@ static int cursor_push_json_elem_array(struct cursor *cur, return 0; break; case NDB_ELEMENT_INT: - val = ndb_filter_get_int_element(elems, i); + val = *ndb_filter_get_int_element(elems, i); if (!cursor_push_int_str(cur, val)) return 0; break; @@ -4910,19 +4910,19 @@ int ndb_filter_json(const struct ndb_filter *filter, char *buf, int buflen) case NDB_FILTER_SINCE: if (!cursor_push_str(c, "\"since\":")) return 0; - if (!cursor_push_int_str(c, ndb_filter_get_int_element(elems, 0))) + if (!cursor_push_int_str(c, *ndb_filter_get_int_element(elems, 0))) return 0; break; case NDB_FILTER_UNTIL: if (!cursor_push_str(c, "\"until\":")) return 0; - if (!cursor_push_int_str(c, ndb_filter_get_int_element(elems, 0))) + if (!cursor_push_int_str(c, *ndb_filter_get_int_element(elems, 0))) return 0; break; case NDB_FILTER_LIMIT: if (!cursor_push_str(c, "\"limit\":")) return 0; - if (!cursor_push_int_str(c, ndb_filter_get_int_element(elems, 0))) + if (!cursor_push_int_str(c, *ndb_filter_get_int_element(elems, 0))) return 0; break; } diff --git a/nostrdb/src/nostrdb.h b/nostrdb/src/nostrdb.h @@ -502,7 +502,7 @@ int ndb_filter_from_json(const char *, int len, struct ndb_filter *filter, unsig // getting field elements unsigned char *ndb_filter_get_id_element(const struct ndb_filter *, const struct ndb_filter_elements *, int index); const char *ndb_filter_get_string_element(const struct ndb_filter *, const struct ndb_filter_elements *, int index); -uint64_t ndb_filter_get_int_element(const struct ndb_filter_elements *, int index); +uint64_t *ndb_filter_get_int_element(struct ndb_filter_elements *, int index); struct ndb_filter_elements *ndb_filter_current_element(const struct ndb_filter *); struct ndb_filter_elements *ndb_filter_get_elements(const struct ndb_filter *, int);