pozmeneny free snake

This commit is contained in:
Kamil Gejdoš 2026-04-14 15:48:42 +00:00
parent 28b8f47f0b
commit 21bc7ca138

View File

@ -36,16 +36,12 @@ struct snake* remove_snake(struct snake* snake){
void free_snake(struct snake* sn){ void free_snake(struct snake* sn){
if (sn == NULL) return; while (sn != NULL) {
struct snake* clanok = sn; //idem pozerat kde su clanky a nacitam aktualny clanok
struct snake* clanok = sn; //idem pozerat kde su clanky
do {
clanok = sn;//nacitam aktualny clanok
sn = sn -> next;//posuniem sa o clanok sn = sn -> next;//posuniem sa o clanok
free(clanok);//vycistim staru ulozenu poziciu free(clanok);//vycistim staru ulozenu poziciu
} while (sn -> next != NULL); }
free(clanok -> next);
} }
int is_snake(struct snake* snake,int x,int y){ int is_snake(struct snake* snake,int x,int y){