diff options
author | Jon Santmyer <jon@jonsantmyer.com> | 2024-03-11 21:30:31 -0400 |
---|---|---|
committer | Jon Santmyer <jon@jonsantmyer.com> | 2024-03-11 21:30:31 -0400 |
commit | d1ff7bcc91886626dc9060ec5fb67ee102ab7c1d (patch) | |
tree | 8f0b5cd8aad31089131785dc6e37b659490f9955 /lib/hashtable.h | |
download | jove-kernel-d1ff7bcc91886626dc9060ec5fb67ee102ab7c1d.tar.gz jove-kernel-d1ff7bcc91886626dc9060ec5fb67ee102ab7c1d.tar.bz2 jove-kernel-d1ff7bcc91886626dc9060ec5fb67ee102ab7c1d.zip |
usermode capable kernel with logging syscall
Diffstat (limited to 'lib/hashtable.h')
-rw-r--r-- | lib/hashtable.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/hashtable.h b/lib/hashtable.h new file mode 100644 index 0000000..fe6f5c3 --- /dev/null +++ b/lib/hashtable.h @@ -0,0 +1,34 @@ +#ifndef JOVE_LIB_HASHTABLE_H +#define JOVE_LIB_HASHTABLE_H 1 + +#include <stddef.h> +#include <stdint.h> +#include "linkedlist.h" + +struct HashTableValue +{ + const void *key; + char value[]; +}; + +struct HashTable { + struct SLinkedList *buckets; + size_t bucket_count; + size_t bucket_capacity; + + size_t obj_size; + int key_size; + size_t (*hash_function)(const void*, size_t); +}; + +void _hashtable_new(struct HashTable *table, size_t obj_size, size_t key_size); +#define hashtable_new(table, type, keytype) _hashtable_new(table, sizeof(type), sizeof(keytype)) + +void _hashtable_news(struct HashTable *table, size_t obj_size); +#define hashtable_news(table, type) _hashtable_news(table, sizeof(type)) + +void hashtable_insert(struct HashTable *table, const void *key, void *data); +void *_hashtable_get(struct HashTable *table, const void *key); +#define hashtable_get(table, key, type) (type*)_hashtable_get(table, key) + +#endif |