]> git.ipfire.org Git - thirdparty/bind9.git/commit
Add isc_hashmap API that implements Robin Hood hashing
authorOndřej Surý <ondrej@isc.org>
Fri, 24 Jun 2022 06:32:12 +0000 (08:32 +0200)
committerOndřej Surý <ondrej@isc.org>
Thu, 10 Nov 2022 14:07:19 +0000 (15:07 +0100)
commitf46ce447a676ea5ba938934d20d310aec9eef7f5
tree5c3e2d96d334e556f89d6c28d227fe7502374405
parent0744ebe2206fcb327ca0d33e0a722757525e30f0
Add isc_hashmap API that implements Robin Hood hashing

Add new isc_hashmap API that differs from the current isc_ht API in
several aspects:

1. It implements Robin Hood Hashing which is open-addressing hash table
   algorithm (e.g. no linked-lists)

2. No memory allocations - the array to store the nodes is made of
   isc_hashmap_node_t structures instead of just pointers, so there's
   only allocation on resize.

3. The key is not copied into the hashmap node and must be also stored
   externally, either as part of the stored value or in any other
   location that's valid as long the value is stored in the hashmap.

This makes the isc_hashmap_t a little less universal because of the key
storage requirements, but the inserts and deletes are faster because
they don't require memory allocation on isc_hashmap_add() and memory
deallocation on isc_hashmap_delete().
lib/isc/Makefile.am
lib/isc/hashmap.c [new file with mode: 0644]
lib/isc/include/isc/hashmap.h [new file with mode: 0644]
tests/isc/Makefile.am
tests/isc/hashmap_test.c [new file with mode: 0644]
tests/isc/ht_test.c