use GFX2_malloc() to log allocation errors

also check malloc() return more often
This commit is contained in:
Thomas Bernard
2019-05-04 17:52:34 +02:00
parent 7f78f3ec72
commit c051ac2189
8 changed files with 139 additions and 102 deletions

View File

@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <string.h>
#include "gfx2surface.h"
#include "gfx2mem.h"
#include "errors.h"
T_GFX2_Surface * New_GFX2_Surface(word width, word height)
@@ -32,10 +33,10 @@ T_GFX2_Surface * New_GFX2_Surface(word width, word height)
if (size == 0) // surfaces with no pixels not allowed
return NULL;
surface = malloc(sizeof(T_GFX2_Surface));
surface = GFX2_malloc(sizeof(T_GFX2_Surface));
if (surface == NULL)
return NULL;
surface->pixels = malloc(size);
surface->pixels = GFX2_malloc(size);
if(surface->pixels == NULL)
{
free(surface);