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. * deletes a package from the cache entry.
*/ */
void void
pkg_cache_delete(pkg_t *pkg) pkg_cache_remove(pkg_t *pkg)
{ {
if (pkg->prev != NULL) if (pkg->prev != NULL)
pkg->prev->next = pkg->next; pkg->prev->next = pkg->next;

29
pkg.c
View File

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