From 7b807a35a8dc63f9742cecf0fc3db46c30e28b0d Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Thu, 2 May 2019 11:42:51 +0200 Subject: misc: Add twalk_r function The twalk function is very difficult to use in a multi-threaded program because there is no way to pass external state to the iterator function. Reviewed-by: Carlos O'Donell Reviewed-by: Adhemerval Zanella --- misc/search.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'misc/search.h') diff --git a/misc/search.h b/misc/search.h index 47e8a43436..4659c59877 100644 --- a/misc/search.h +++ b/misc/search.h @@ -150,6 +150,13 @@ typedef void (*__action_fn_t) (const void *__nodep, VISIT __value, extern void twalk (const void *__root, __action_fn_t __action); #ifdef __USE_GNU +/* Like twalk, but pass down a closure parameter instead of the + level. */ +extern void twalk_r (const void *__root, + void (*) (const void *__nodep, VISIT __value, + void *__closure), + void *__closure); + /* Callback type for function to free a tree node. If the keys are atomic data this function should do nothing. */ typedef void (*__free_fn_t) (void *__nodep); -- cgit 1.4.1