From 8f20c7b30abee1436fe7ab0b7fbdb57a3f14b849 Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Wed, 1 May 2024 23:52:32 +0100 Subject: [PATCH] Update image creation function --- src/image/image.c | 9 +++++---- src/image/image.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/image/image.c b/src/image/image.c index c1c049f..c0a9edc 100644 --- a/src/image/image.c +++ b/src/image/image.c @@ -8,17 +8,18 @@ Image *create_image(u64 width, u64 height, Pixel *data, Arena *arena) { return NULL; } - u64 buf_length = width * height; - u64 total_size = sizeof(Image) + sizeof(Pixel) * buf_length; + u64 pixel_count = width * height; + u64 buf_length = sizeof(Pixel) * pixel_count; + u64 alloc_size = sizeof(Image) + buf_length; - Image *img = wapp_mem_arena_alloc(arena, total_size); + Image *img = wapp_mem_arena_alloc(arena, alloc_size); if (!img) { return NULL; } img->width = width; img->height = height; - img->buf_length = buf_length; + img->pixel_count = pixel_count; memcpy(img->data, data, buf_length); return img; diff --git a/src/image/image.h b/src/image/image.h index e071838..424f8db 100644 --- a/src/image/image.h +++ b/src/image/image.h @@ -20,7 +20,7 @@ typedef struct image Image; struct image { u64 width; u64 height; - u64 buf_length; + u64 pixel_count; Pixel data[]; };