summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzabolcs Nagy <nsz@port70.net>2013-10-29 20:25:11 +0000
committerSzabolcs Nagy <nsz@port70.net>2013-10-29 20:25:11 +0000
commitb7d3210196ff3508601a9f57ad18315eb25f7330 (patch)
tree9b839d2486faeaa323b94879673ff04185bb2a2e
parent7e01b8f09b6d50991472e0198c4959b085884dec (diff)
downloadmusl-b7d3210196ff3508601a9f57ad18315eb25f7330.tar.gz
POSIX conformance fix: define struct entry in search.h
-rw-r--r--include/search.h2
-rw-r--r--src/search/hsearch.c16
2 files changed, 9 insertions, 9 deletions
diff --git a/include/search.h b/include/search.h
index ebfe08a2..27f61072 100644
--- a/include/search.h
+++ b/include/search.h
@@ -13,7 +13,7 @@ extern "C" {
typedef enum { FIND, ENTER } ACTION;
typedef enum { preorder, postorder, endorder, leaf } VISIT;
-typedef struct {
+typedef struct entry {
char *key;
void *data;
} ENTRY;
diff --git a/src/search/hsearch.c b/src/search/hsearch.c
index be856b2a..6fe5ced0 100644
--- a/src/search/hsearch.c
+++ b/src/search/hsearch.c
@@ -14,14 +14,14 @@ with the posix api items cannot be iterated and length cannot be queried
#define MINSIZE 8
#define MAXSIZE ((size_t)-1/2 + 1)
-struct entry {
+struct elem {
ENTRY item;
size_t hash;
};
static size_t mask;
static size_t used;
-static struct entry *tab;
+static struct elem *tab;
static size_t keyhash(char *k)
{
@@ -37,9 +37,9 @@ static int resize(size_t nel)
{
size_t newsize;
size_t i, j;
- struct entry *e, *newe;
- struct entry *oldtab = tab;
- struct entry *oldend = tab + mask + 1;
+ struct elem *e, *newe;
+ struct elem *oldtab = tab;
+ struct elem *oldend = tab + mask + 1;
if (nel > MAXSIZE)
nel = MAXSIZE;
@@ -81,10 +81,10 @@ void hdestroy(void)
used = 0;
}
-static struct entry *lookup(char *key, size_t hash)
+static struct elem *lookup(char *key, size_t hash)
{
size_t i, j;
- struct entry *e;
+ struct elem *e;
for (i=hash,j=1; ; i+=j++) {
e = tab + (i & mask);
@@ -98,7 +98,7 @@ static struct entry *lookup(char *key, size_t hash)
ENTRY *hsearch(ENTRY item, ACTION action)
{
size_t hash = keyhash(item.key);
- struct entry *e = lookup(item.key, hash);
+ struct elem *e = lookup(item.key, hash);
if (e->item.key)
return &e->item;