Initialization
This commit is contained in:
		
							parent
							
								
									f3cfad99f8
								
							
						
					
					
						commit
						9bb83fabba
					
				
							
								
								
									
										20
									
								
								cv9/snake.c
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								cv9/snake.c
									
									
									
									
									
								
							| @ -10,17 +10,23 @@ 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) { | ||||||
|     struct snake* head = calloc(1,sizeof(struct snake)); |     struct snake* temp = snake; | ||||||
|     struct snake* this = head; |     if (snake!= NULL) { | ||||||
|     this = this->next; |         snake = snake->next; | ||||||
|     this = head; |         free(temp); | ||||||
|     while (this != NULL){ |  | ||||||
|         this= this->next; |  | ||||||
|     } |     } | ||||||
|     return head; |     return snake; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void free_snake(struct snake* sn) { | void free_snake(struct snake* sn) { | ||||||
|  |     struct snake* current = sn; | ||||||
|  |     struct snake* next; | ||||||
|  | 
 | ||||||
|  |     while (current!= NULL) { | ||||||
|  |         next = current->next; | ||||||
|  |         free(current); | ||||||
|  |         current = 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