Esempio n. 1
0
static void
test_pkg_list_new(void)
{
	struct pkg_list *l1, *l2, *l3;
	struct pkginfo pkg;

	l1 = pkg_list_new(&pkg, NULL);
	test_pass(l1 != NULL);
	test_pass(l1->next == NULL);
	test_pass(l1->pkg == &pkg);

	l2 = pkg_list_new(&pkg, l1);
	test_pass(l2 != NULL);
	test_pass(l2->next == l1);
	test_pass(l2->pkg == &pkg);

	l3 = pkg_list_new(&pkg, l2);
	test_pass(l3 != NULL);
	test_pass(l3->next == l2);
	test_pass(l3->pkg == &pkg);

	pkg_list_free(l3);
}
Esempio n. 2
0
struct pkg_list *
pkg_queue_push(struct pkg_queue *queue, struct pkginfo *pkg)
{
	struct pkg_list *node;

	node = pkg_list_new(pkg, NULL);

	if (queue->tail == NULL)
		queue->head = node;
	else
		queue->tail->next = node;

	queue->tail = node;

	queue->length++;

	return node;
}
Esempio n. 3
0
/**
 * Prepend a package list node to a package list.
 *
 * @param head The head of the list to prepend to.
 * @param pkg The pkginfo to prepend to the list.
 */
void
pkg_list_prepend(struct pkg_list **head, struct pkginfo *pkg)
{
	*head = pkg_list_new(pkg, *head);
}