aboutsummaryrefslogtreecommitdiff
path: root/hashtable.c
diff options
context:
space:
mode:
authormescalinum <mescalinum@users.sourceforge.net>2011-10-15 15:52:29 +0000
committermescalinum <mescalinum@users.sourceforge.net>2011-10-15 15:52:29 +0000
commit5d7b51638d572ab41557c5a80ebff69d9320e740 (patch)
treeb410b6f83981de7eb4000a295661f089018d02fd /hashtable.c
parentf7dd0d906c42c7f0e0e5d5fecc8d987b35901d75 (diff)
add list length
svn path=/trunk/externals/loaders/tclpd/; revision=15604
Diffstat (limited to 'hashtable.c')
-rw-r--r--hashtable.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/hashtable.c b/hashtable.c
index ae32d38..0b4409f 100644
--- a/hashtable.c
+++ b/hashtable.c
@@ -58,12 +58,22 @@ void* list_get(list_node_t* head, const char* k) {
return (void*)0;
}
+size_t list_length(list_node_t* head) {
+ size_t length = 0;
+ while(head) {
+ length++;
+ head = head->next;
+ }
+ return length;
+}
+
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->sz = 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;
}