From 43c42c28e63b41da41785bf106f7a5069717127d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 22 Jul 2017 18:46:33 +0100 Subject: [PATCH] Cleanup font_renderer_create_atlas --- gfx/drivers_font_renderer/freetype.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/gfx/drivers_font_renderer/freetype.c b/gfx/drivers_font_renderer/freetype.c index 51017f8ec4..88f4d9eaa5 100644 --- a/gfx/drivers_font_renderer/freetype.c +++ b/gfx/drivers_font_renderer/freetype.c @@ -173,16 +173,20 @@ static bool font_renderer_create_atlas(ft_font_renderer_t *handle, float font_si unsigned max_width = font_size + 2; unsigned max_height = font_size + 2; - handle->atlas.width = max_width * FT_ATLAS_COLS; - handle->atlas.height = max_height * FT_ATLAS_ROWS; + unsigned atlas_width = max_width * FT_ATLAS_COLS; - handle->atlas.buffer = (uint8_t*) - calloc(handle->atlas.width * handle->atlas.height, 1); + unsigned atlas_height = max_height * FT_ATLAS_ROWS; - if (!handle->atlas.buffer) + uint8_t *atlas_buffer = (uint8_t*) + calloc(atlas_width * atlas_height, 1); + + if (!atlas_buffer) return false; - slot = handle->atlas_slots; + handle->atlas.buffer = atlas_buffer; + handle->atlas.width = atlas_width; + handle->atlas.height = atlas_height; + slot = handle->atlas_slots; for (y = 0; y < FT_ATLAS_ROWS; y++) {