mirror of
https://github.com/0intro/wmii
synced 2024-11-25 07:09:38 +03:00
fixed error in container.c, but still a weird bug on move
This commit is contained in:
parent
4948c0db18
commit
8bc2c9fc0f
@ -20,7 +20,8 @@ static void detach_from_stack(Container *c, CItem *i)
|
|||||||
/* remove from stack */
|
/* remove from stack */
|
||||||
if (i == c->stack) {
|
if (i == c->stack) {
|
||||||
c->stack = i->down;
|
c->stack = i->down;
|
||||||
c->stack->up = 0;
|
if (c->stack)
|
||||||
|
c->stack->up = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (i->up)
|
if (i->up)
|
||||||
@ -64,14 +65,18 @@ void cext_detach_item(Container *c, void *item)
|
|||||||
CItem *i = c->list;
|
CItem *i = c->list;
|
||||||
if (!i)
|
if (!i)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* remove from list */
|
/* remove from list */
|
||||||
if (i->item == item)
|
if (i->item == item)
|
||||||
c->list = c->list->next;
|
c->list = i->next;
|
||||||
else {
|
else {
|
||||||
|
CItem *tmp;
|
||||||
for (; i->next && (i->next->item != item); i = i->next);
|
for (; i->next && (i->next->item != item); i = i->next);
|
||||||
if (!i->next)
|
if (!i->next)
|
||||||
return;
|
return;
|
||||||
i->next = i->next->next;
|
tmp = i;
|
||||||
|
i = i->next;
|
||||||
|
tmp->next = tmp->next->next;
|
||||||
}
|
}
|
||||||
detach_from_stack(c, i);
|
detach_from_stack(c, i);
|
||||||
free(i);
|
free(i);
|
||||||
|
@ -19,13 +19,22 @@ int main(int argc, char *argv[])
|
|||||||
Container c = {0};
|
Container c = {0};
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
printf("--------------------------------\n");
|
||||||
|
{
|
||||||
|
int *e = cext_emalloc(sizeof(int));
|
||||||
|
cext_attach_item(&c, e);
|
||||||
|
cext_iterate(&c, nil, iter_print_container);
|
||||||
|
cext_detach_item(&c, e);
|
||||||
|
cext_iterate(&c, nil, iter_print_container);
|
||||||
|
}
|
||||||
|
printf("--------------------------------\n");
|
||||||
|
|
||||||
|
printf("--------------------------------\n");
|
||||||
for (i = 0; i < 10; i++) {
|
for (i = 0; i < 10; i++) {
|
||||||
int *e = cext_emalloc(sizeof(int));
|
int *e = cext_emalloc(sizeof(int));
|
||||||
*e = i;
|
*e = i;
|
||||||
cext_attach_item(&c, e);
|
cext_attach_item(&c, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("--------------------------------\n");
|
|
||||||
cext_iterate(&c, nil, iter_print_container);
|
cext_iterate(&c, nil, iter_print_container);
|
||||||
printf("--------------------------------\n");
|
printf("--------------------------------\n");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user