X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fsearch%2Ftsearch_avl.c;h=86200928ef6c6390a0d8c8563d7a375e92c01605;hb=ac0acd569e01735fc6052d43fdf57f3a07c93f3d;hp=b56159b9baf05041ba3958cb8bf949602574190f;hpb=6255c4c6a5599724d18311a7776aebe67f8e6d4a;p=musl diff --git a/src/search/tsearch_avl.c b/src/search/tsearch_avl.c index b56159b9..86200928 100644 --- a/src/search/tsearch_avl.c +++ b/src/search/tsearch_avl.c @@ -138,9 +138,13 @@ static struct node *remove(struct node **n, const void *k, void *tdelete(const void *restrict key, void **restrict rootp, int(*compar)(const void *, const void *)) { + struct node *n = *rootp; + struct node *ret; /* last argument is arbitrary non-null pointer which is returned when the root node is deleted */ - return remove((void*)rootp, key, compar, *rootp); + ret = remove(&n, key, compar, n); + *rootp = n; + return ret; } void *tfind(const void *key, void *const *rootp, @@ -153,7 +157,11 @@ void *tsearch(const void *key, void **rootp, int (*compar)(const void *, const void *)) { int new = 0; - return insert((void*)rootp, key, compar, &new); + struct node *n = *rootp; + struct node *ret; + ret = insert(&n, key, compar, &new); + *rootp = n; + return ret; } static void walk(const struct node *r, void (*action)(const void *, VISIT, int), int d)