15#define HTABLE_NEEDS_TO_GROW(table) (table->size > 0 && table->capacity / table->size < 2)
16#define HTABLE_NEEDS_TO_SHRINK(table) (table->size > 0 && table->capacity / table->size > 8)
18#define HTABLE_SUCCESS ( 0)
19#define HTABLE_ENOVAL (-1)
20#define HTABLE_EINVAL (-2)
21#define HTABLE_ENOMEM (-3)
57#define HTABLE_MIN_SIZE (8)
95 if (table == NULL ||
key == NULL) {
133 if (table == NULL ||
key == NULL) {
164 if (table == NULL ||
key == NULL || out == NULL) {
184 uint64_t hash = 5381;
186 while ((
c = *
string++)) {
187 hash = ((hash << 5) + hash) +
c;
203 (*table)->buckets =
papi_calloc(size,
sizeof(*(*table)->buckets));
204 if ((*table)->buckets == NULL) {
209 (*table)->capacity = size;
235 for (old_id = 0; old_id < old_table->
capacity; ++old_id) {
294 uint64_t new_capacity = (resize & 0x2) ?
325 if (*entry == NULL) {
328 (*entry)->key = strdup(
key);
330 (*entry)->next = NULL;
368 if (table->
buckets[
id] == entry) {
406 while (curr && strcmp(curr->
key,
key)) {
static papi_handle_t handle
static double c[MATRIX_SIZE][MATRIX_SIZE]
Return codes and api definitions.
#define papi_calloc(a, b)
static int find_table_entry(struct hash_table *, const char *, struct hash_table_entry **)
static uint64_t hash_func(const char *)
static int destroy_table(struct hash_table *)
static int rehash_table(struct hash_table *, struct hash_table *)
static int create_table_entry(const char *, void *, struct hash_table_entry **)
static int destroy_table_entry(struct hash_table_entry *)
static int htable_insert(void *handle, const char *key, void *in)
static int htable_delete(void *handle, const char *key)
static int insert_table_entry(struct hash_table *, struct hash_table_entry *)
static int delete_table_entry(struct hash_table *, struct hash_table_entry *)
static int htable_shutdown(void *handle)
static int create_table(uint64_t, struct hash_table **)
static int check_n_resize_table(struct hash_table *)
#define HTABLE_NEEDS_TO_SHRINK(table)
#define HTABLE_NEEDS_TO_GROW(table)
static int htable_find(void *handle, const char *key, void **out)
static int move_table(struct hash_table *, struct hash_table *)
static int htable_init(void **handle)
static int destroy_table_entries(struct hash_table *)
struct hash_table_entry * next
struct hash_table_entry ** buckets