diff --git a/src/image.c b/src/image.c index 38b8d6e..f6de50b 100644 --- a/src/image.c +++ b/src/image.c @@ -28,3 +28,18 @@ Image *create_image(u64 width, u64 height, Pixel *data, 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); +} diff --git a/src/image.h b/src/image.h index eb27493..433f47a 100644 --- a/src/image.h +++ b/src/image.h @@ -26,6 +26,7 @@ struct image { Image *create_image(u64 width, u64 height, Pixel *data, const Allocator *allocator); +void destroy_image(Image **img, const Allocator *allocator); #ifdef __cplusplus }