aboutsummaryrefslogtreecommitdiff
path: root/hashtable.c
diff options
context:
space:
mode:
authormescalinum <mescalinum@users.sourceforge.net>2011-11-13 22:52:33 +0000
committermescalinum <mescalinum@users.sourceforge.net>2011-11-13 22:52:33 +0000
commitc80ad601728139c16c4903f5ed08680f7e5f203c (patch)
treeab8d9484489355b9877eecf05e859a02d8bb7e14 /hashtable.c
parent8dd16881e82ee2b655049367968ebd8d28d1d9cc (diff)
0.3.0 - typemaps support complete
svn path=/trunk/externals/loaders/tclpd/; revision=15738
Diffstat (limited to 'hashtable.c')
-rw-r--r--hashtable.c24
1 files changed, 12 insertions, 12 deletions
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);