libroot: Reinstate tdestroy.
It was removed in hrev55422 as we never had declared it in any headers. But it seems some software came to depend on it anyway. Reinstate it, and add a declaration for it, behind _GNU_SOURCE.
This commit is contained in:
parent
aa04f48dcf
commit
ffbe2ad946
@ -49,6 +49,10 @@ extern void *tsearch(const void *key, void **_root,
|
||||
extern void twalk(const void *root,
|
||||
void (*action)(const void *, VISIT, int ));
|
||||
|
||||
#ifdef _GNU_SOURCE
|
||||
extern void tdestroy(void *root, void (*free_key)(void *))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -13,6 +13,7 @@ for architectureObject in [ MultiArchSubDirSetup ] {
|
||||
insque.c
|
||||
lsearch.c
|
||||
tdelete.c
|
||||
tdestroy.c
|
||||
tfind.c
|
||||
tsearch.c
|
||||
twalk.c
|
||||
|
16
src/system/libroot/posix/musl/search/tdestroy.c
Normal file
16
src/system/libroot/posix/musl/search/tdestroy.c
Normal file
@ -0,0 +1,16 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <stdlib.h>
|
||||
#include <search.h>
|
||||
#include "tsearch.h"
|
||||
|
||||
void tdestroy(void *root, void (*freekey)(void *))
|
||||
{
|
||||
struct node *r = root;
|
||||
|
||||
if (r == 0)
|
||||
return;
|
||||
tdestroy(r->a[0], freekey);
|
||||
tdestroy(r->a[1], freekey);
|
||||
if (freekey) freekey((void *)r->key);
|
||||
free(r);
|
||||
}
|
Loading…
Reference in New Issue
Block a user