projects
/
libc-test
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
math/gen: yet another little decimal formatting tool
[libc-test]
/
src
/
functional
/
search_hsearch.c
diff --git
a/src/functional/search_hsearch.c
b/src/functional/search_hsearch.c
index
0bd6529
..
dc1538e
100644
(file)
--- a/
src/functional/search_hsearch.c
+++ b/
src/functional/search_hsearch.c
@@
-1,3
+1,4
@@
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <search.h>
#include <stdlib.h>
#include <string.h>
#include <search.h>
@@
-12,6
+13,8
@@
#define get(k) hsearch((ENTRY){.key = k, .data = 0}, FIND)
#define get(k) hsearch((ENTRY){.key = k, .data = 0}, FIND)
+#define getdata(e) ((intptr_t)(e)->data)
+
int main()
{
ENTRY *e;
int main()
{
ENTRY *e;
@@
-35,14
+38,14
@@
int main()
if (get("c"))
t_error("hsearch FIND c should fail\n");
set("g", 10);
if (get("c"))
t_error("hsearch FIND c should fail\n");
set("g", 10);
- if (e &&
(int)(e->data
) != 7)
- t_error("hsearch ENTER g 10 returned data %d, wanted 7\n",
(int)(e->data
));
+ if (e &&
getdata(e
) != 7)
+ t_error("hsearch ENTER g 10 returned data %d, wanted 7\n",
getdata(e
));
set("g", 10);
set("g", 10);
- if (e &&
(int)(e->data
) != 7)
- t_error("hsearch ENTER g 10 returned data %d, wanted 7\n",
(int)(e->data
));
+ if (e &&
getdata(e
) != 7)
+ t_error("hsearch ENTER g 10 returned data %d, wanted 7\n",
getdata(e
));
set("j", 10);
set("j", 10);
- if (e &&
(int)(e->data
) != 10)
- t_error("hsearch ENTER j 10 returned data %d, wanted 10\n",
(int)(e->data
));
+ if (e &&
getdata(e
) != 10)
+ t_error("hsearch ENTER j 10 returned data %d, wanted 10\n",
getdata(e
));
hdestroy();
return t_status;
}
hdestroy();
return t_status;
}