From c141e7e44e13f7fbae7d683b7066fa25b6a1ebf1 Mon Sep 17 00:00:00 2001 From: Michal Utlak Date: Tue, 9 Apr 2024 16:50:26 +0200 Subject: [PATCH] nova hlavicka --- cv9/snake.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/cv9/snake.c b/cv9/snake.c index 92baaf5..8237939 100644 --- a/cv9/snake.c +++ b/cv9/snake.c @@ -3,10 +3,7 @@ struct snake* add_snake(struct snake* snake,int x,int y){ struct snake* hlavicka = calloc(1,sizeof(struct snake)); - if (hlavicka == NULL) { - return NULL; - } - + hlavicka->x = x; hlavicka->y = y; @@ -16,7 +13,15 @@ struct snake* add_snake(struct snake* snake,int x,int y){ } 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; + } + + return nova_hlavicka; } void free_snake(struct snake* sn){