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.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'hashtable.c') diff --git a/hashtable.c b/hashtable.c index c2fa96f..6d69c5e 100644 --- a/hashtable.c +++ b/hashtable.c @@ -12,8 +12,8 @@ uint32_t hash_str(const char *s) { return h ^ (h >> 16); } -list_node_t* list_add(list_node_t* head, const char* k, void* v) { - list_node_t* n = (list_node_t*)malloc(sizeof(list_node_t)); +list_node_t * list_add(list_node_t *head, const char *k, void *v) { + list_node_t *n = (list_node_t *)malloc(sizeof(list_node_t)); n->next = head; #ifdef HASHTABLE_COPY_KEYS n->k = strdup(k); @@ -24,10 +24,10 @@ list_node_t* list_add(list_node_t* head, const char* k, void* v) { return n; } -list_node_t* list_remove(list_node_t* head, const char* k) { +list_node_t * list_remove(list_node_t *head, const char *k) { if(!head) return NULL; - list_node_t* tmp; + list_node_t *tmp; // head remove while(head && strcmp(head->k, k) == 0) { @@ -39,7 +39,7 @@ list_node_t* list_remove(list_node_t* head, const char* k) { free(tmp); } - list_node_t* p = head; + list_node_t *p = head; // normal (non-head) remove while(p->next) { @@ -59,7 +59,7 @@ list_node_t* list_remove(list_node_t* head, const char* k) { return head; } -list_node_t* list_get(list_node_t* head, const char* k) { +list_node_t * list_get(list_node_t *head, const char *k) { while(head) { if(strcmp(head->k, k) == 0) { return head; @@ -69,7 +69,7 @@ list_node_t* list_get(list_node_t* head, const char* k) { return NULL; } -size_t list_length(list_node_t* head) { +size_t list_length(list_node_t *head) { size_t length = 0; while(head) { length++; @@ -78,18 +78,18 @@ size_t list_length(list_node_t* head) { return length; } -hash_table_t* hashtable_new(size_t size) { - hash_table_t* ht = NULL; +hash_table_t * hashtable_new(size_t size) { + hash_table_t *ht = NULL; if(size > 0) { - ht = (hash_table_t*)malloc(sizeof(hash_table_t)); + ht = (hash_table_t *)malloc(sizeof(hash_table_t)); ht->sz = size; - ht->t = (list_node_t**)malloc(sizeof(list_node_t*) * size); + ht->t = (list_node_t **)malloc(sizeof(list_node_t *) * size); for(int i = 0; i < size; i++) ht->t[i] = NULL; } return ht; } -void hashtable_free(hash_table_t* ht) { +void hashtable_free(hash_table_t *ht) { if(ht) { free(ht->t); free(ht); -- cgit v1.2.1