domaca_uloha_7

This commit is contained in:
Tomáš Vasiľ 2022-04-26 20:28:43 +02:00
parent 33861f4a21
commit 220b417b95

View File

@ -16,6 +16,8 @@ struct snake* add_snake(struct snake* snake,int x,int y){
} }
struct snake* remove_snake(struct snake* snake){ struct snake* remove_snake(struct snake* snake){
if (snake == NULL) return NULL;
struct snake* nasledujuci = calloc(1, sizeof(struct snake)); struct snake* nasledujuci = calloc(1, sizeof(struct snake));
nasledujuci = snake->next; nasledujuci = snake->next;
free(snake); free(snake);
@ -31,6 +33,8 @@ void free_snake(struct snake* sn){
free(sn); free(sn);
sn = nasledujuci; sn = nasledujuci;
} }
free(nasledujuci);
} }
int is_snake(struct snake* snake,int x,int y){ int is_snake(struct snake* snake,int x,int y){