diff --git a/cv9/snake.c b/cv9/snake.c index a2ae686..5d2df07 100644 --- a/cv9/snake.c +++ b/cv9/snake.c @@ -18,11 +18,23 @@ struct snake* remove_snake(struct snake* snake){ return NULL; } - struct snake* nova_hlavicka = snake->next; + struct snake* nova_hlavicka = snake->next; free(snake); - assert(nova_hlavicka == NULL || nova_hlavicka->next == NULL); + + if (nova_hlavicka == NULL || nova_hlavicka->next == NULL) { + assert(nova_hlavicka == NULL || nova_hlavicka->next == NULL); + return nova_hlavicka; + } + + + struct snake* chvost = nova_hlavicka; + while (chvost->next != NULL) { + chvost = chvost->next; + } + + assert(chvost->next == NULL); return nova_hlavicka; }