From 8d90e27f154c6d387cc9fae15e27fc9b5c48efb3 Mon Sep 17 00:00:00 2001 From: Matheus Date: Tue, 2 Aug 2022 21:44:27 -0300 Subject: [PATCH] hashtable entrycount --- src/include/hashtable.h | 3 ++- src/include/hashtable/hashtable.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/include/hashtable.h b/src/include/hashtable.h index a3c724ec..7f165aa1 100644 --- a/src/include/hashtable.h +++ b/src/include/hashtable.h @@ -12,6 +12,7 @@ typedef struct{ typedef struct{ size_t size; + size_t entrycount; hashtableentry* entries; } hashtable; @@ -20,6 +21,6 @@ bool hashtable_insert(hashtable*, char*, void*); bool hashtable_remove(hashtable*, char*); void hashtable_destroy(hashtable*); void* hashtable_get(hashtable*, char*); -bool* hashtable_set(hashtable*, char*, void*); +bool hashtable_set(hashtable*, char*, void*); #endif diff --git a/src/include/hashtable/hashtable.c b/src/include/hashtable/hashtable.c index 940470bf..1d4585cc 100644 --- a/src/include/hashtable/hashtable.c +++ b/src/include/hashtable/hashtable.c @@ -52,7 +52,8 @@ bool hashtable_insert(hashtable* table, char* key, void* val){ entry->key = keysave; entry->val = val; - + ++table->entrycount; + return true; } @@ -88,9 +89,9 @@ bool hashtable_remove(hashtable* table, char* key){ else{ memset(entry, 0, sizeof(hashtableentry)); } - return true; } + --table->entrycount; return true;