[pacman-dev] memleak caused by "don't duplicate package in cache"

Xavier shiningxc at gmail.com
Sun Feb 10 04:16:28 EST 2008

Aaron Griffin wrote:
> I'm still a fan of handling this sort of thing internally to the list
> structure, so we gain something like this:
> struct alpm_list_head {
> ...
> ...
> void (*free_func)(void*);
> ...
> };
> then the lists which require free-ing of the internal members have
> this set and it is called on alpm_list_free() is non-NULL. Say, for
> instance, the cache lists get a free_func = list_free_pkg, all the
> packages would get free'd when the list is free'd
> This way we could cover this case here, when we hit the case that the
> packages need freeing, we simply set the free_func to be non-NULL and
> that base is covered.

But, here we have two different lists, cache_list and target_list which 
share the same packages.
In the normal case, we have cache_list == target_list (they have the 
same size, and share the same packages, but not the same nodes).
But an error can happen at any step. So we could have an empty 
cache_list, or only one package in it, or two, etc..

More information about the pacman-dev mailing list