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){