Some algorithms need with a stack or a working list from which the last element can be removed. The ptrlist API has a function to do this but it's not typed and thus needs a wrapper for each type it's used for. Simplify this by adding a generic (but type-safe) macro for this while also giving it a nicer name: pop_ptr_list(). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- ptrlist.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ptrlist.h b/ptrlist.h index 3b952097545f..0b06142252f5 100644 --- a/ptrlist.h +++ b/ptrlist.h @@ -67,6 +67,12 @@ extern void **__add_ptr_list_tag(struct ptr_list **, void *, unsigned long); (__typeof__(&(ptr))) __add_ptr_list_tag(head, ptr, tag);\ }) +#define pop_ptr_list(l) ({ \ + PTRLIST_TYPE(*(l)) ptr; \ + ptr = delete_ptr_list_last((struct ptr_list**)(l)); \ + ptr; \ + }) + extern void __free_ptr_list(struct ptr_list **); #define free_ptr_list(list) do { \ VRFY_PTR_LIST(*(list)); \ -- 2.30.0