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

Aaron Griffin aaronmgriffin at gmail.com
Sat Feb 9 20:28:56 EST 2008


On Feb 6, 2008 9:07 AM, Xavier <shiningxc at gmail.com> wrote:
> So, for solving this issue, maybe we would need a way to track down
> which packages were loaded in the cache. That should allow us to free
> everything correctly, which doesn't seem possible currently.
> We could then free in the trans_free function all targets that are not
> in the pkg cache. And the remaining targets that are in the pkg cache
> will be freed when the cache is freed.

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.




More information about the pacman-dev mailing list