ngx_list_free

Yuval Abadi y.abadi at f5.com
Tue Apr 18 15:12:08 UTC 2023


Thanks

I just need  list   not queue,


And I want to free the whole list , not one node.



-----Original Message-----
From: nginx <nginx-bounces at nginx.org> On Behalf Of Maxim Dounin
Sent: Tuesday, 18 April 2023 15:36
To: Yuval Abadi via nginx <nginx at nginx.org>
Subject: Re: ngx_list_free

EXTERNAL MAIL: nginx-bounces at nginx.org

Hello!

On Tue, Apr 18, 2023 at 06:14:46AM +0000, Yuval Abadi via nginx wrote:

> Ngx_list_t   have create api but no free_list api
>
> Why?
>
> I wrote my own free_list,  is anyone else   face this  issue?

Much like many things in nginx, ngx_list_t structure is an append-only structure, and it is expected to be used as a list of items being added.  Most notably, ngx_list_t is used for request headers (these are added to the list when they are parsed), and response headers (these are added when they are generated internally).

If you have to remove an item for some reason (which shouldn't be common case for legitimate usage, but might happen to be needed occasionally), the common approach is to use a "skip" flag in the structures being listed.  For example, response headers are cleared by setting the "hash" field to 0, so such headers are ignored by the code iterating over the list.

If you need something more dynamic in your code, ngx_list_t might not be the right structure to use.  Something like ngx_queue_t or ngx_rbtree_t might be a better choice.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list
nginx at nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx


More information about the nginx mailing list