mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-17 18:40:14 +00:00
92f120d446
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.
32 lines
454 B
C
32 lines
454 B
C
#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;
|
|
}
|