This commit is contained in:
Michal Utľák 2024-04-09 17:04:30 +02:00
parent 8b6ffcb16b
commit 78f05087c6

View File

@ -18,22 +18,17 @@ struct snake* remove_snake(struct snake* snake){
return NULL;
}
struct snake* nova_hlavicka = snake->next;
free(snake);
if (nova_hlavicka == NULL || nova_hlavicka->next == NULL) {
assert(nova_hlavicka == NULL || nova_hlavicka->next == NULL);
return nova_hlavicka;
if (nova_hlavicka == NULL) {
return NULL;
}
struct snake* chvost = nova_hlavicka;
while (chvost->next != NULL) {
chvost = chvost->next;
}
assert(chvost->next == NULL);
return nova_hlavicka;