Hash :
cdac22fc
Author :
Date :
2012-07-29T04:04:46
queue: fix iteration ordering bug
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
/*
* queue.c
* compilation of a list of packages into a world dependency set
*
* Copyright (c) 2012 pkgconf authors (see AUTHORS).
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* This software is provided 'as is' and without any warranty, express or
* implied. In no event shall the authors be liable for any damages arising
* from the use of this software.
*/
#include "pkg.h"
#include "bsdstubs.h"
pkg_queue_t *
pkg_queue_push(pkg_queue_t *parent, const char *package)
{
pkg_queue_t *pkgq = calloc(sizeof(pkg_queue_t), 1);
pkgq->package = strdup(package);
pkgq->prev = parent;
if (pkgq->prev != NULL)
pkgq->prev->next = pkgq;
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, next_pkgq, pkgq)
{
free(pkgq->package);
free(pkgq);
}
}