diff options
author | Ulrich Drepper <drepper@redhat.com> | 2002-01-29 08:25:15 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2002-01-29 08:25:15 +0000 |
commit | 92f120d446433f74d4d2612587bb38a992050a04 (patch) | |
tree | 3cbab71124841be7472ab55114b9123fd54a9038 /misc/tst-hsearch.c | |
parent | fa8d436c87f156d18208df3819fecee9fc1dbd9e (diff) | |
download | glibc-92f120d446433f74d4d2612587bb38a992050a04.tar.gz glibc-92f120d446433f74d4d2612587bb38a992050a04.tar.xz glibc-92f120d446433f74d4d2612587bb38a992050a04.zip |
Update.
2002-01-29 Ulrich Drepper <drepper@redhat.com> * 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.
Diffstat (limited to 'misc/tst-hsearch.c')
-rw-r--r-- | misc/tst-hsearch.c | 31 |
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; +} |