Add destroy_image function
This commit is contained in:
		
							
								
								
									
										15
									
								
								src/image.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								src/image.c
									
									
									
									
									
								
							| @@ -28,3 +28,18 @@ Image *create_image(u64 width, u64 height, Pixel *data, | |||||||
|  |  | ||||||
|   return img; |   return img; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void destroy_image(Image **img, const Allocator *allocator) { | ||||||
|  |   if (!img || !(*img)) { | ||||||
|  |     return; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   Allocator alloc; | ||||||
|  |   if (!allocator) { | ||||||
|  |     alloc = wapp_mem_libc_allocator(); | ||||||
|  |   } else { | ||||||
|  |     alloc = *allocator; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   wapp_mem_allocator_free(&alloc, (void **)img); | ||||||
|  | } | ||||||
|   | |||||||
| @@ -26,6 +26,7 @@ struct image { | |||||||
|  |  | ||||||
| Image *create_image(u64 width, u64 height, Pixel *data, | Image *create_image(u64 width, u64 height, Pixel *data, | ||||||
|                     const Allocator *allocator); |                     const Allocator *allocator); | ||||||
|  | void destroy_image(Image **img, const Allocator *allocator); | ||||||
|  |  | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user