queue: add pkg_queue_compile() and pkg_queue_free().

feature/tap-sh
William Pitcock 2012-07-29 03:56:20 -05:00
parent 698358e9d4
commit f4f1c1defe
2 changed files with 33 additions and 0 deletions

2
pkg.h
View File

@ -173,5 +173,7 @@ extern FILE *error_msgout;
/* queue.c */
pkg_queue_t *pkg_queue_push(pkg_queue_t *parent, const char *package);
bool pkg_queue_compile(pkg_t *world, pkg_queue_t *head);
void pkg_queue_free(pkg_queue_t *head);
#endif

31
queue.c
View File

@ -28,3 +28,34 @@ pkg_queue_push(pkg_queue_t *parent, const char *package)
return pkgq;
}
bool
pkg_queue_compile(pkg_t *world, pkg_queue_t *head)
{
pkg_queue_t *pkgq;
PKG_FOREACH_LIST_ENTRY(head, pkgq)
{
pkg_dependency_t *pkgdep;
pkgdep = pkg_dependency_parse(world, pkgq->package);
if (pkgdep != NULL)
world->requires = pkg_dependency_append(world->requires, pkgdep);
else
return false;
}
return true;
}
void
pkg_queue_free(pkg_queue_t *head)
{
pkg_queue_t *pkgq, *next_pkgq;
PKG_FOREACH_LIST_ENTRY_SAFE(head, pkgq, next_pkgq)
{
free(pkgq->package);
free(pkgq);
}
}