Move allocation failure check closer to allocation

This commit is contained in:
Luflosi 2019-09-03 12:05:28 +02:00
parent 40b4fb966f
commit 2d06ee5822
No known key found for this signature in database
GPG Key ID: 14140F703B7D8362
2 changed files with 5 additions and 7 deletions

View File

@ -1260,7 +1260,6 @@ send_prerendered_sprites_for_window(OSWindow *w) {
FontGroup *fg = (FontGroup*)w->fonts_data; FontGroup *fg = (FontGroup*)w->fonts_data;
if (!fg->sprite_map) { if (!fg->sprite_map) {
fg->sprite_map = alloc_sprite_map(fg->cell_width, fg->cell_height); fg->sprite_map = alloc_sprite_map(fg->cell_width, fg->cell_height);
if (!fg->sprite_map) fatal("Out of memory allocating a sprite map");
send_prerendered_sprites(fg); send_prerendered_sprites(fg);
} }
} }

View File

@ -37,12 +37,11 @@ alloc_sprite_map(unsigned int cell_width, unsigned int cell_height) {
sprite_tracker_set_limits(max_texture_size, max_array_texture_layers); sprite_tracker_set_limits(max_texture_size, max_array_texture_layers);
} }
SpriteMap *ans = calloc(1, sizeof(SpriteMap)); SpriteMap *ans = calloc(1, sizeof(SpriteMap));
if (ans) { if (!ans) fatal("Out of memory allocating a sprite map");
*ans = NEW_SPRITE_MAP; *ans = NEW_SPRITE_MAP;
ans->max_texture_size = max_texture_size; ans->max_texture_size = max_texture_size;
ans->max_array_texture_layers = max_array_texture_layers; ans->max_array_texture_layers = max_array_texture_layers;
ans->cell_width = cell_width; ans->cell_height = cell_height; ans->cell_width = cell_width; ans->cell_height = cell_height;
}
return (SPRITE_MAP_HANDLE)ans; return (SPRITE_MAP_HANDLE)ans;
} }