From 92f120d446433f74d4d2612587bb38a992050a04 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 29 Jan 2002 08:25:15 +0000 Subject: Update. 2002-01-29 Ulrich Drepper * misc/hsearch_r.c (hsearch_r): Don't insert anything if entry is found. * misc/Makefile (tests): Add tst-hsearch. * misc/tst-hsearch.c: New file. --- misc/tst-hsearch.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 misc/tst-hsearch.c (limited to 'misc/tst-hsearch.c') 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 +#include + +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; +} -- cgit v1.2.3