diff options
| author | steven-na <noreply.github@stvnc.dev> | 2026-08-21 23:16:44 -0700 |
|---|---|---|
| committer | steven-na <noreply.github@stvnc.dev> | 2026-08-21 23:16:44 -0700 |
| commit | fee3f00c6d8a855b4372a0367e0b3e9dcea76699 (patch) | |
| tree | ab423c6b1f43e3eb53c88a6a55a95d932fbbd19b /src/map.c | |
| parent | b844718a1687424b2748608cbb52fb4012417fe5 (diff) | |
Added printf attr to log funcs
Diffstat (limited to 'src/map.c')
| -rw-r--r-- | src/map.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -1,10 +1,10 @@ #include "map.h" #include "common.h" #include "smrt_arena.h" +#include "log.h" #include "../include/a5hash.h" -#include <immintrin.h> #include <stdint.h> #include <string.h> @@ -34,6 +34,11 @@ map_t map_create(smrt_arena_t *arena, u64 capacity) { map->values = SMRTA_ALLOC_ARRAY(arena, void*, capacity); map->table_size = capacity; + #ifndef NLOG_TRACE + log_trace("Created hashmap; Total capacity %lu", + capacity); + #endif /* ifndef NLOG_TRACE */ + return map; } @@ -73,6 +78,8 @@ i32 map_insert(map_t const map, u8 const *key, u64 keylen, void *value) { } } + log_warn("Attempted to insert value with key \"%.*s...\" into hashmap that is full", + (i32)MIN(5, keylen), key); return -1; } @@ -107,7 +114,7 @@ void *map_lookup(map_t const map, u8 const *key, u64 keylen) { u64 tsize = map->table_size; for (u64 i = start; i != start - 1; i = (i+1)%tsize) { u8 h_lookupcmp = map->hashlookup[i]; - if (h_lookupcmp == ENTRY_EMPTY) return NULL; + if (h_lookupcmp == ENTRY_EMPTY) break; if (h_lookupcmp == ENTRY_TOMBSTONE) continue; map_key_entry_t k = map->keys[i]; @@ -115,7 +122,7 @@ void *map_lookup(map_t const map, u8 const *key, u64 keylen) { h == map->hashes[i] && k.keylen == keylen && (memcmp(key, k.key, keylen) == 0)) - { return map->values[i]; } + { return map->values[i]; } } return NULL; |