From c80ad601728139c16c4903f5ed08680f7e5f203c Mon Sep 17 00:00:00 2001 From: mescalinum Date: Sun, 13 Nov 2011 22:52:33 +0000 Subject: 0.3.0 - typemaps support complete svn path=/trunk/externals/loaders/tclpd/; revision=15738 --- hashtable.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'hashtable.h') diff --git a/hashtable.h b/hashtable.h index f2d1a4a..a45de35 100644 --- a/hashtable.h +++ b/hashtable.h @@ -6,38 +6,38 @@ #include typedef struct list_node { - const char* k; - void* v; - struct list_node* next; + const char *k; + void *v; + struct list_node *next; } list_node_t; typedef struct hash_table { - list_node_t** t; + list_node_t **t; size_t sz; } hash_table_t; uint32_t hash_str(const char *s); -list_node_t* list_add(list_node_t* head, const char* k, void* v); -list_node_t* list_remove(list_node_t* head, const char* k); -list_node_t* list_get(list_node_t* head, const char* k); -size_t list_length(list_node_t* head); +list_node_t * list_add(list_node_t *head, const char *k, void *v); +list_node_t * list_remove(list_node_t *head, const char *k); +list_node_t * list_get(list_node_t *head, const char *k); +size_t list_length(list_node_t *head); -hash_table_t* hashtable_new(size_t size); -void hash_table_free(hash_table_t* ht); +hash_table_t * hashtable_new(size_t size); +void hash_table_free(hash_table_t *ht); -static inline void hashtable_add(hash_table_t* ht, const char* name, void* c) { +static inline void hashtable_add(hash_table_t *ht, const char *name, void *c) { uint32_t h = hash_str(name) % ht->sz; - ht->t[h] = list_add(ht->t[h], name, (void*)c); -} + ht->t[h] = list_add(ht->t[h], name, (void *)c); +} -static inline void hashtable_remove(hash_table_t* ht, const char* name) { +static inline void hashtable_remove(hash_table_t *ht, const char *name) { uint32_t h = hash_str(name) % ht->sz; ht->t[h] = list_remove(ht->t[h], name); } -static inline void* hashtable_get(hash_table_t* ht, const char* name) { +static inline void * hashtable_get(hash_table_t *ht, const char *name) { uint32_t h = hash_str(name) % ht->sz; - list_node_t* n = list_get(ht->t[h], name); + list_node_t *n = list_get(ht->t[h], name); return n ? n->v : NULL; } -- cgit v1.2.1