implement hcreate_r, hdestroy_r and hsearch_r

the size and alignment of struct hsearch_data are matched to the glibc
definition for binary compatibility. the members of the structure do
not match, which should not be a problem as long as applications
correctly treat the structure as opaque.

unlike the glibc implementation, this version of hcreate_r does not
require the caller to zero-fill the structure before use.
This commit is contained in:
sin 2014-03-25 16:37:51 +00:00 • committed by Rich Felker
commit fe1ba7dbf1
2 changed files with 86 additions and 31 deletions

View file

@ -22,6 +22,18 @@ int hcreate(size_t);
void hdestroy(void);
ENTRY *hsearch(ENTRY, ACTION);
#ifdef _GNU_SOURCE
struct hsearch_data {
struct __tab *__tab;
unsigned int __unused1;
unsigned int __unused2;
};
int hcreate_r(size_t, struct hsearch_data *);
void hdestroy_r(struct hsearch_data *);
int hsearch_r(ENTRY, ACTION, ENTRY **, struct hsearch_data *);
#endif
void insque(void *, void *);
void remque(void *);