hashtable: static define macro

This commit is contained in:
Matheus
2025-07-23 17:40:33 -03:00
parent 3f953eb6c9
commit 819551330b
+9 -1
View File
@@ -15,7 +15,7 @@ typedef struct hashentry_t {
} hashentry_t;
typedef struct {
size_t entrycount;
size_t entrycount; // for bookkeeping
size_t capacity;
hashentry_t **entries;
} hashtable_t;
@@ -30,4 +30,12 @@ int hashtable_destroy(hashtable_t *table);
for (uintmax_t toffset = 0; toffset < (table)->capacity; ++toffset) \
for (hashentry_t *entry = (table)->entries[toffset]; entry != NULL; entry = entry->next)
#define HASHTABLE_DEFINE_STATIC(name, size) \
static hashentry_t *entries_ht_##name[size]; \
static hashtable_t name = { \
.entrycount = 0, \
.capacity = size, \
.entries = entries_ht_##name \
}
#endif