aboutsummaryrefslogtreecommitdiff
path: root/misc/tst-hsearch.c
diff options
context:
space:
mode:
Diffstat (limited to 'misc/tst-hsearch.c')
-rw-r--r--misc/tst-hsearch.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/misc/tst-hsearch.c b/misc/tst-hsearch.c
new file mode 100644
index 0000000000..6c19b22472
--- /dev/null
+++ b/misc/tst-hsearch.c
@@ -0,0 +1,31 @@
+#include <search.h>
+#include <stdio.h>
+
+int
+main (void)
+{
+ int a = 1;
+ int b = 2;
+ ENTRY i;
+ ENTRY *e;
+
+ if (hcreate (20) == 0)
+ {
+ puts ("hcreate failed");
+ return 1;
+ }
+
+ i.key = (char *) "one";
+ i.data = &a;
+ if (hsearch (i, ENTER) == NULL)
+ return 1;
+
+ i.key = (char *) "one";
+ i.data = &b;
+ e = hsearch (i, ENTER);
+ printf ("e.data = %d\n", *(int *) e->data);
+ if (*(int *) e->data != 1)
+ return 1;
+
+ return 0;
+}