pkg: use pkg_cache APIs.

pull/48/head
William Pitcock 2013-02-25 22:40:30 -06:00
parent 9439b02936
commit c9831c1ed0
2 changed files with 7 additions and 28 deletions

View File

@ -55,12 +55,12 @@ pkg_cache_add(pkg_t *pkg)
}
/*
* pkg_cache_delete
* pkg_cache_remove(pkg)
*
* deletes a package from the cache entry.
*/
void
pkg_cache_delete(pkg_t *pkg)
pkg_cache_remove(pkg_t *pkg)
{
if (pkg->prev != NULL)
pkg->prev->next = pkg->next;

31
pkg.c
View File

@ -140,8 +140,6 @@ pkg_get_parent_dir(pkg_t *pkg)
return buf;
}
static pkg_t *pkg_cache = NULL;
/*
* pkg_new_from_file(filename, file, flags)
*
@ -249,14 +247,7 @@ pkg_free(pkg_t *pkg)
if (pkg == NULL || pkg->flags & PKG_PROPF_VIRTUAL)
return;
if (pkg->next != NULL)
pkg->next->prev = pkg->prev;
if (pkg->prev != NULL)
pkg->prev->next = pkg->next;
if (pkg == pkg_cache)
pkg_cache = pkg->next;
pkg_cache_remove(pkg);
pkg_dependency_free(pkg->requires);
pkg_dependency_free(pkg->requires_private);
@ -444,16 +435,8 @@ pkg_find(const char *name, unsigned int flags)
/* check cache */
if (!(flags & PKGF_NO_CACHE))
{
PKG_FOREACH_LIST_ENTRY(pkg_cache, pkg)
{
if (!strcmp(pkg->id, name))
{
pkg->flags |= PKG_PROPF_CACHED;
return pkg;
}
}
pkg = NULL;
if ((pkg = pkg_cache_lookup(name)) != NULL)
return pkg;
}
/* PKG_CONFIG_PATH has to take precedence */
@ -493,13 +476,9 @@ pkg_find(const char *name, unsigned int flags)
#endif
out:
if (pkg != NULL && !(flags & PKGF_NO_CACHE))
{
pkg->next = pkg_cache;
pkg_cache = pkg;
}
pkg_cache_add(pkg);
path_free(path, count);
return pkg;
}