libpkgconf: cache: refactor the way package objects are marked as cached to avoid memory leaks (#133)
parent
048deb95b3
commit
9b55fc3c23
|
@ -84,6 +84,9 @@ pkgconf_cache_add(pkgconf_client_t *client, pkgconf_pkg_t *pkg)
|
||||||
pkgconf_node_insert(&pkg->cache_iter, pkg, &client->pkg_cache);
|
pkgconf_node_insert(&pkg->cache_iter, pkg, &client->pkg_cache);
|
||||||
|
|
||||||
PKGCONF_TRACE(client, "added @%p to cache", pkg);
|
PKGCONF_TRACE(client, "added @%p to cache", pkg);
|
||||||
|
|
||||||
|
/* mark package as cached */
|
||||||
|
pkg->flags |= PKGCONF_PKG_PROPF_CACHED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -103,6 +106,9 @@ pkgconf_cache_remove(pkgconf_client_t *client, pkgconf_pkg_t *pkg)
|
||||||
if (pkg == NULL)
|
if (pkg == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!(pkg->flags & PKGCONF_PKG_PROPF_CACHED))
|
||||||
|
return;
|
||||||
|
|
||||||
PKGCONF_TRACE(client, "removed @%p from cache", pkg);
|
PKGCONF_TRACE(client, "removed @%p from cache", pkg);
|
||||||
|
|
||||||
pkgconf_node_delete(&pkg->cache_iter, &client->pkg_cache);
|
pkgconf_node_delete(&pkg->cache_iter, &client->pkg_cache);
|
||||||
|
|
|
@ -688,8 +688,6 @@ pkgconf_pkg_find(pkgconf_client_t *client, const char *name)
|
||||||
if ((pkg = pkgconf_cache_lookup(client, name)) != NULL)
|
if ((pkg = pkgconf_cache_lookup(client, name)) != NULL)
|
||||||
{
|
{
|
||||||
PKGCONF_TRACE(client, "%s is cached", name);
|
PKGCONF_TRACE(client, "%s is cached", name);
|
||||||
|
|
||||||
pkg->flags |= PKGCONF_PKG_PROPF_CACHED;
|
|
||||||
return pkg;
|
return pkg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue