summaryrefslogtreecommitdiffstats
path: root/libdimension/canvas.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2009-10-26 00:25:21 -0400
committerTavian Barnes <tavianator@gmail.com>2009-10-26 00:25:21 -0400
commitc6612fb215d71ac2bea3b614786cf585cd1a6c74 (patch)
treefa8a4d6eb0bc83ba112b8c1b03b212641669c002 /libdimension/canvas.c
parente4e3ea4fd58cbbe462368abde728f9443f01de19 (diff)
downloaddimension-c6612fb215d71ac2bea3b614786cf585cd1a6c74.tar.xz
Clean up some dmnsn_new_*() functions.
Rather than special-case every failed memory allocation, just make dmnsn_delete_*() more robust and call it.
Diffstat (limited to 'libdimension/canvas.c')
-rw-r--r--libdimension/canvas.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libdimension/canvas.c b/libdimension/canvas.c
index 1d74a33..eacd8f6 100644
--- a/libdimension/canvas.c
+++ b/libdimension/canvas.c
@@ -34,15 +34,15 @@ dmnsn_new_canvas(unsigned int x, unsigned int y)
canvas->x = x;
canvas->y = y;
+ /* Allocate room for the optimizers */
+ canvas->optimizers = dmnsn_new_array(sizeof(dmnsn_canvas_optimizer));
+
/* Allocate the pixels */
canvas->pixels = malloc(sizeof(dmnsn_color)*x*y);
if (!canvas->pixels) {
- free(canvas);
+ dmnsn_delete_canvas(canvas);
return NULL;
}
-
- /* Allocate room for the optimizers */
- canvas->optimizers = dmnsn_new_array(sizeof(dmnsn_canvas_optimizer));
}
return canvas;