aboutsummaryrefslogtreecommitdiff
path: root/lib/hash.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2006-09-10 22:12:24 +0000
committerDaniel Stenberg <daniel@haxx.se>2006-09-10 22:12:24 +0000
commitf2a33eb372ec958dbb0c5eeeab546eedbaa617c2 (patch)
treebfb452caa27bddc403b6dba32b30f0402f9045a0 /lib/hash.c
parente134a4020885701b583b8af2e9d0414b090512f6 (diff)
Added a useful debug function within #if 0. The function makes it easy to
"dump" a hash table which is useful when tracking problems with data stored in one of our hashes.
Diffstat (limited to 'lib/hash.c')
-rw-r--r--lib/hash.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/lib/hash.c b/lib/hash.c
index 26ea9c475..e00462778 100644
--- a/lib/hash.c
+++ b/lib/hash.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -282,3 +282,34 @@ Curl_hash_destroy(struct curl_hash *h)
free(h);
}
+#if 0 /* useful function for debugging hashes and their contents */
+void Curl_hash_print(struct curl_hash *h,
+ void (*func)(void *))
+{
+ int i;
+ struct curl_llist_element *le;
+ struct curl_llist *list;
+ struct curl_hash_element *he;
+ if (!h)
+ return;
+
+ fprintf(stderr, "=Hash dump=\n");
+
+ for (i = 0; i < h->slots; i++) {
+ list = h->table[i];
+ le = list->head; /* get first list entry */
+ if(le) {
+ fprintf(stderr, "index %d:", i);
+ while(le) {
+ he = le->ptr;
+ if(func)
+ func(he->ptr);
+ else
+ fprintf(stderr, " [%p]", he->ptr);
+ le = le->next;
+ }
+ fprintf(stderr, "\n");
+ }
+ }
+}
+#endif