17#define HTABLE_SUCCESS ( 0)
18#define HTABLE_ENOVAL (-1)
19#define HTABLE_EINVAL (-2)
20#define HTABLE_ENOMEM (-3)
22#define HTABLE_NEEDS_TO_GROW(table) (table->size > 0 && table->capacity / table->size < 2)
23#define HTABLE_NEEDS_TO_SHRINK(table) (table->size > 0 && table->capacity / table->size > 8)
59#define HTABLE_MIN_SIZE (8)
97 if (table == NULL ||
key == NULL) {
135 if (table == NULL ||
key == NULL) {
166 if (table == NULL ||
key == NULL || out == NULL) {
186 uint64_t hash = 5381;
188 while ((
c = *
string++)) {
189 hash = ((hash << 5) + hash) +
c;
205 (*table)->buckets =
papi_calloc(size,
sizeof(*(*table)->buckets));
206 if ((*table)->buckets == NULL) {
211 (*table)->capacity = size;
237 for (old_id = 0; old_id < old_table->
capacity; ++old_id) {
295 uint64_t new_capacity = (resize & 0x2) ?
326 if (*entry == NULL) {
329 (*entry)->key = strdup(
key);
331 (*entry)->next = NULL;
369 if (table->
buckets[
id] == entry) {
407 while (curr && strcmp(curr->
key,
key)) {
static papi_handle_t handle
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 *)
static double c[MATRIX_SIZE][MATRIX_SIZE]
Return codes and api definitions.
#define papi_calloc(a, b)
struct hash_table_entry * next
struct hash_table_entry ** buckets