Re: Free a list_head

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

 



On 7/11/06, Om. <om.turyx@xxxxxxxxx> wrote:
On 7/11/06, Fernando Apesteguía <fernando.apesteguia@xxxxxxxxx> wrote:
> Hi,
>
> I would like to know how to free a list_head.
>
> I have almost 200 elements and I'm wonder if I must traverse the list for
> all the elements and do:
>
> list_for_each(...){
>    my_entry=list_entry(....)
>     list_del(my_entry)
>    kfree(my_entry)
> }
Don't use it. Use lit_for_each_safe()
From include/linux/list.h,

list_for_each_entry_safe - iterate over list of given type safe
against removal of list entry
Free each element's individually kmalloc()-ed pointers first as well.
HTH,
Om.

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux