diff options
author | Tavian Barnes <tavianator@gmail.com> | 2009-10-26 00:25:21 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2009-10-26 00:25:21 -0400 |
commit | c6612fb215d71ac2bea3b614786cf585cd1a6c74 (patch) | |
tree | fa8a4d6eb0bc83ba112b8c1b03b212641669c002 /libdimension/canvas.c | |
parent | e4e3ea4fd58cbbe462368abde728f9443f01de19 (diff) | |
download | dimension-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.c | 8 |
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; |