pozmeneny free snake
This commit is contained in:
parent
28b8f47f0b
commit
21bc7ca138
12
du4/snake.c
12
du4/snake.c
@ -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){
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user