From 88a1e65f90fbac14f2d95c02586c3de95ca340c4 Mon Sep 17 00:00:00 2001 From: Haoran Zhang Date: Sun, 18 Aug 2024 19:51:13 -0700 Subject: [PATCH] art_insert returns 0 on success --- src/include/art.h | 2 +- src/libpgmoneta/art.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/include/art.h b/src/include/art.h index 7013705a..bebcf7f0 100644 --- a/src/include/art.h +++ b/src/include/art.h @@ -87,7 +87,7 @@ pgmoneta_art_destroy(struct art* tree); * @param key_len The length of the key * @param value The value data * @param type The value type - * @return 0 if the item was newly inserted, otherwise 1 + * @return 0 if the item was successfully inserted, otherwise 1 */ int pgmoneta_art_insert(struct art* t, unsigned char* key, uint32_t key_len, uintptr_t value, enum value_type type); diff --git a/src/libpgmoneta/art.c b/src/libpgmoneta/art.c index 8fe2af1e..34e5c187 100644 --- a/src/libpgmoneta/art.c +++ b/src/libpgmoneta/art.c @@ -340,7 +340,7 @@ pgmoneta_art_insert(struct art* t, unsigned char* key, uint32_t key_len, uintptr if (t == NULL) { // c'mon, at least create a tree first... - return 0; + goto error; } old_val = art_node_insert(t->root, &t->root, 0, key, key_len, value, type, &new); pgmoneta_value_destroy(old_val); @@ -348,6 +348,8 @@ pgmoneta_art_insert(struct art* t, unsigned char* key, uint32_t key_len, uintptr { t->size++; } + return 0; +error: return 1; }