diff --git a/du7/snake.c b/du7/snake.c index d837b78..21a3077 100644 --- a/du7/snake.c +++ b/du7/snake.c @@ -27,11 +27,10 @@ struct snake* remove_snake(struct snake* snake){ struct snake* medzipamat = calloc(1, sizeof(struct snake)); medzipamat = snake; - while (1) { - snake = snake->next; - if (snake->next->next == NULL) break; - } + while (snake->next->next != NULL) snake = snake->next; + free(snake->next); + snake->next = NULL; snake = medzipamat;