From dd56776a0e6fa3e955343b51963772adab39d3a3 Mon Sep 17 00:00:00 2001 From: Miloslav Macko Date: Wed, 10 Apr 2024 23:15:35 +0200 Subject: [PATCH] =?UTF-8?q?1=C3=A9.4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cv9/snake.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cv9/snake.c b/cv9/snake.c index 58f0b29..27ee822 100644 --- a/cv9/snake.c +++ b/cv9/snake.c @@ -18,12 +18,18 @@ struct snake* remove_snake(struct snake* snake) { // Snake is empty return NULL; } + if (!snake->next) { + // Snake has only one part + free(snake); + return NULL; + } struct snake* new_head = snake->next; free(snake); return new_head; } + int is_snake(struct snake* snake, int x, int y) { while (snake) { if (snake->x == x && snake->y == y) {