From 50a8386b753f72a3823b3fac67f29be61e5c6210 Mon Sep 17 00:00:00 2001 From: Dennis Bonke Date: Mon, 30 Oct 2023 00:20:14 +0100 Subject: [PATCH] options/glibc: Add the non *_r variants of hsearch --- options/glibc/generic/search.cpp | 17 +++++++++++++++++ options/glibc/include/bits/glibc/glibc_search.h | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/options/glibc/generic/search.cpp b/options/glibc/generic/search.cpp index a25d87ee6e..1faa7087f6 100644 --- a/options/glibc/generic/search.cpp +++ b/options/glibc/generic/search.cpp @@ -13,6 +13,8 @@ struct _ENTRY { size_t used; }; +static struct hsearch_data htab; + static size_t keyhash(char *k) { unsigned char *p = (unsigned char *)k; size_t h = 0; @@ -123,3 +125,18 @@ void hdestroy_r(struct hsearch_data *htab) { free(htab->table); htab->table = 0; } + +int hcreate(size_t nel) { + return hcreate_r(nel, &htab); +} + +void hdestroy(void) { + hdestroy_r(&htab); +} + +ENTRY *hsearch(ENTRY item, ACTION action) { + ENTRY *e; + + hsearch_r(item, action, &e, &htab); + return e; +} diff --git a/options/glibc/include/bits/glibc/glibc_search.h b/options/glibc/include/bits/glibc/glibc_search.h index e8d9755e3a..cd73eefb1f 100644 --- a/options/glibc/include/bits/glibc/glibc_search.h +++ b/options/glibc/include/bits/glibc/glibc_search.h @@ -27,6 +27,10 @@ struct hsearch_data { #ifndef __MLIBC_ABI_ONLY +int hcreate(size_t nel); +void hdestroy(void); +ENTRY *hsearch(ENTRY item, ACTION action); + int hsearch_r(ENTRY item, ACTION action, ENTRY **ret, struct hsearch_data *htab); int hcreate_r(size_t num_elements, struct hsearch_data *htab); void hdestroy_r(struct hsearch_data *htab);