diff --git a/du7/snake.c b/du7/snake.c index e8d5350..da890dc 100644 --- a/du7/snake.c +++ b/du7/snake.c @@ -10,20 +10,18 @@ struct snake* add_snake(struct snake* snake, int x, int y) { } struct snake* remove_snake(struct snake* snake) { - struct snake* prev = NULL; - struct snake* curr = snake; - while (curr->next != NULL) { - prev = curr; - curr = curr->next; - } - free(curr); - if (prev != NULL) { - prev->next = NULL; - return snake; - } else { - return NULL; - } +struct snake* this = head; +this = this->next; +while (this->next != NULL){ + this = this->next; } +this = head; +while (this != NULL){ + // Niečo môžme s prvkom this spraviť + this= this->next; +} +} + void free_snake(struct snake* sn) { while (sn != NULL) {