Add destroy_image function

This commit is contained in:
Abdelrahman Said 2024-04-20 18:41:41 +01:00
parent 3e0b1762d1
commit 7f6ffd0fea
2 changed files with 16 additions and 0 deletions

View File

@ -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);
}

View File

@ -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
} }