Re: [PATCH 3/6] ptrlist: add pop_ptr_list()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 06/03/2021 10:05, Luc Van Oostenryck wrote:
> Some algorithms need with a stack or a working list from which the

s/with a stack/a stack/

ATB,
Ramsay Jones

> 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));					\
> 



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux