Exemplo n.º 1
0
Arquivo: list.c Projeto: atroel/basics
static int walk()
{
	B6_LIST_DEFINE(list);
	struct b6_dref dref[16];
	struct b6_dref *iter;
	int i;

	for (i = 0; i < b6_card_of(dref); i += 1)
		if (&dref[i] != b6_list_add_last(&list, &dref[i]))
			return 0;

	for (i = 0, iter = b6_list_first(&list); iter != b6_list_tail(&list);
	     iter = b6_list_walk(iter, B6_NEXT), i += 1)
		if (iter != &dref[i])
			return 0;

	if (i != b6_card_of(dref))
		return 0;

	for (i = 0, iter = b6_list_last(&list); iter != b6_list_head(&list);
	     iter = b6_list_walk(iter, B6_PREV), i += 1)
		if (iter != &dref[b6_card_of(dref) - 1 - i])
			return 0;

	if (i != b6_card_of(dref))
		return 0;

	return 1;
}
Exemplo n.º 2
0
Arquivo: list.c Projeto: atroel/basics
static int del()
{
	B6_LIST_DEFINE(list);
	struct b6_dref dref[3];
	int i;

	for (i = 0; i < b6_card_of(dref); i += 1)
		if (&dref[i] != b6_list_add_last(&list, &dref[i]))
			return 0;

	for (i = 0; i < b6_card_of(dref); i += 1) {
		if (&dref[b6_card_of(dref) - 1] != b6_list_last(&list))
			return 0;

		if (&dref[i] != b6_list_del(&dref[i]))
			return 0;
	}

	if (b6_list_head(&list) != b6_list_last(&list))
		return 0;

	if (!b6_list_empty(&list))
		return 0;

	return 1;
}
Exemplo n.º 3
0
Arquivo: list.c Projeto: atroel/basics
static int del_head()
{
	B6_LIST_DEFINE(list);
	int retval;
	jmp_buf env;

	retval = setjmp(env);
	if (!retval) {
		test_handler = &env;
		b6_list_del(b6_list_head(&list));
	}

	return retval;
}
Exemplo n.º 4
0
void previous_menu_entry(struct menu *self)
{
	walk_menu_entry(self, B6_PREV, b6_list_head(&self->entries),
			b6_list_last(&self->entries));
}
Exemplo n.º 5
0
Arquivo: list.c Projeto: atroel/basics
static int last_is_head_when_empty()
{
	B6_LIST_DEFINE(list);

	return b6_list_last(&list) == b6_list_head(&list);
}