summaryrefslogtreecommitdiffstats
path: root/src/hash.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-09-14 17:19:12 -0400
committerDavid Robillard <d@drobilla.net>2021-09-14 17:19:12 -0400
commit19235b7127bcf5597fb0436deb45c2e6af5843c6 (patch)
treebb0207a4799f67933cd793e0501d09a10822c5ec /src/hash.c
parent9572ea596d07147dbfb6db7772623e740ce28652 (diff)
downloadzix-19235b7127bcf5597fb0436deb45c2e6af5843c6.tar.gz
zix-19235b7127bcf5597fb0436deb45c2e6af5843c6.tar.bz2
zix-19235b7127bcf5597fb0436deb45c2e6af5843c6.zip
Make ZixAllocator a single flat struct
I can never decide between these two patterns for polymorphic objects in C, but this one seems more appropriate here since it's more conducive to inheritance.
Diffstat (limited to 'src/hash.c')
-rw-r--r--src/hash.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/hash.c b/src/hash.c
index 65f9570..fa920b0 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -13,24 +13,24 @@ typedef struct ZixHashEntry {
} ZixHashEntry;
struct ZixHashImpl {
- const ZixAllocator* allocator; ///< User allocator
- ZixKeyFunc key_func; ///< User key accessor
- ZixHashFunc hash_func; ///< User hashing function
- ZixKeyEqualFunc equal_func; ///< User equality comparison function
- size_t count; ///< Number of records stored in the table
- size_t mask; ///< Bit mask for fast modulo (n_entries - 1)
- size_t n_entries; ///< Power of two table size
- ZixHashEntry* entries; ///< Pointer to dynamically allocated table
+ ZixAllocator* allocator; ///< User allocator
+ ZixKeyFunc key_func; ///< User key accessor
+ ZixHashFunc hash_func; ///< User hashing function
+ ZixKeyEqualFunc equal_func; ///< User equality comparison function
+ size_t count; ///< Number of records stored in the table
+ size_t mask; ///< Bit mask for fast modulo (n_entries - 1)
+ size_t n_entries; ///< Power of two table size
+ ZixHashEntry* entries; ///< Pointer to dynamically allocated table
};
static const size_t min_n_entries = 4u;
static const size_t tombstone = 0xDEADu;
ZixHash*
-zix_hash_new(const ZixAllocator* const allocator,
- const ZixKeyFunc key_func,
- const ZixHashFunc hash_func,
- const ZixKeyEqualFunc equal_func)
+zix_hash_new(ZixAllocator* const allocator,
+ const ZixKeyFunc key_func,
+ const ZixHashFunc hash_func,
+ const ZixKeyEqualFunc equal_func)
{
assert(key_func);
assert(hash_func);