Re: Free a list_head

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

 



On Tue, 2006-07-11 at 18:09 +0200, Fernando Apesteguía 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)
> }
> 
> Should I do this in this way?

no you should at least use list_for_each_safe() if you're doing this...
(hint: list_for_each caches the next pointer and your code would kfree
this next pointer's memory....)




--
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