From f4f1c1defe8ce8645dc20f7d1bc292690939b84d Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sun, 29 Jul 2012 03:56:20 -0500 Subject: [PATCH] queue: add pkg_queue_compile() and pkg_queue_free(). --- pkg.h | 2 ++ queue.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/pkg.h b/pkg.h index 96fd31f..c3f55fe 100644 --- a/pkg.h +++ b/pkg.h @@ -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 diff --git a/queue.c b/queue.c index 277b3f9..48fa233 100644 --- a/queue.c +++ b/queue.c @@ -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); + } +}