1
0
mirror of https://github.com/opencryptoki/opencryptoki.git synced 2026-10-24 05:39:17 +03:00

1 Commits

Author SHA1 Message Date
Juergen Christ
1026d2a244 API: Add hashmap
Add a hashmap.  Hashmap uses hashing with chaining to store the different
key/value pairs.  The hash uses a power-of-2 size and simply uses the lower
bits of the hash value to place and locate the element.  Since, e.g.,
mechanisms are highly redundant at the lowest bits, the hash can be configured
to either full Jenkins hash or just the Jenkins mix function.  This is a
compile time option.

The values stored in the hash are designed as a union of a CK_ULONG or a
pointer.  This should allow for maximum flexibility of the user.  Memory
management of the value is left to the user.  The hashmap_free() function
takes a pointer to a user-provided free function that is applied to all values
in the hashmap.  The function can be NULL.

All other functions that would remove a value from the map (either
hashmap_delete or hashmap_add which overwrites the old value with the new
value if the key is already in the map) provide the old value to the user.  It
is then up to the user to free any memory associated with this value.

Signed-off-by: Juergen Christ <jchrist@linux.ibm.com>
2021-11-08 16:29:24 +01:00