aboutsummaryrefslogtreecommitdiff
path: root/tests/test39.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test39.c')
-rw-r--r--tests/test39.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/test39.c b/tests/test39.c
new file mode 100644
index 000000000..18a0af8b4
--- /dev/null
+++ b/tests/test39.c
@@ -0,0 +1,34 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "uthash.h"
+
+typedef struct {
+ const char *name;
+ UT_hash_handle hh;
+} ns_t;
+
+int main()
+{
+ const char *keys[] = {"eins", "zwei", "drei"};
+ unsigned i;
+ ns_t *nsp;
+ ns_t *head = NULL;
+
+ for(i=0; i < (sizeof(keys)/sizeof(keys[0])); i++) {
+ printf("adding key %s\n", keys[i]);
+ nsp = (ns_t*)malloc(sizeof(ns_t));
+ if (nsp == NULL) {
+ exit(-1);
+ }
+ nsp->name = keys[i];
+ HASH_ADD_KEYPTR(hh,head,nsp->name,strlen(nsp->name),nsp);
+ }
+ printf("hash count is %u\n", HASH_COUNT(head));
+
+ for(i=0; i < (sizeof(keys)/sizeof(keys[0])); i++) {
+ printf("looking for key %s... ", keys[i]);
+ HASH_FIND(hh,head,keys[i],strlen(keys[i]),nsp);
+ printf("%s.\n", (nsp!=NULL)?"found":"not found");
+ }
+ return 0;
+}