From 220b417b95619a24a8851df80c359ea11450c896 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Vasi=C4=BE?= Date: Tue, 26 Apr 2022 20:28:43 +0200 Subject: [PATCH] domaca_uloha_7 --- du7/snake.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/du7/snake.c b/du7/snake.c index 0b08096..fd25b4c 100644 --- a/du7/snake.c +++ b/du7/snake.c @@ -16,6 +16,8 @@ struct snake* add_snake(struct snake* snake,int x,int y){ } struct snake* remove_snake(struct snake* snake){ + if (snake == NULL) return NULL; + struct snake* nasledujuci = calloc(1, sizeof(struct snake)); nasledujuci = snake->next; free(snake); @@ -31,6 +33,8 @@ void free_snake(struct snake* sn){ free(sn); sn = nasledujuci; } + + free(nasledujuci); } int is_snake(struct snake* snake,int x,int y){