return NULL;\r
\r
gdx2d_pixmap* pixmap = (gdx2d_pixmap*)malloc(sizeof(gdx2d_pixmap));\r
+ if (!pixmap) return 0;\r
pixmap->width = (uint32_t)width;\r
pixmap->height = (uint32_t)height;\r
pixmap->format = (uint32_t)format;\r
\r
gdx2d_pixmap* gdx2d_new(uint32_t width, uint32_t height, uint32_t format) {\r
gdx2d_pixmap* pixmap = (gdx2d_pixmap*)malloc(sizeof(gdx2d_pixmap));\r
+ if (!pixmap) return 0;\r
pixmap->width = width;\r
pixmap->height = height;\r
pixmap->format = format;\r
pixmap->pixels = (unsigned char*)malloc(width * height * gdx2d_bytes_per_pixel(format));\r
+ if (!pixmap->pixels) {\r
+ free((void*)pixmap);\r
+ return 0;\r
+ }\r
return pixmap;\r
}\r
void gdx2d_free(const gdx2d_pixmap* pixmap) {\r