From 2b087cb45ae91f90492a935625570d7d42ee3ecb Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 7 Apr 2010 14:26:15 -0400 Subject: New dmnsn_malloc() function, and friends. I'm tired of checking for malloc failures everywhere, considering it never happens. So just bail out whenever it does. A lot of stuff is guaranteed to succeed if it returns now. --- libdimension/ambient.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'libdimension/ambient.c') diff --git a/libdimension/ambient.c b/libdimension/ambient.c index 66fabe0..aa1153a 100644 --- a/libdimension/ambient.c +++ b/libdimension/ambient.c @@ -21,7 +21,6 @@ #include "dimension.h" #include #include -#include /* For malloc */ /* * Ambient finish @@ -41,18 +40,13 @@ dmnsn_finish * dmnsn_new_ambient_finish(dmnsn_color ambient) { dmnsn_finish *finish = dmnsn_new_finish(); - if (finish) { - dmnsn_color *param = malloc(sizeof(dmnsn_color)); - if (!param) { - dmnsn_delete_finish(finish); - errno = ENOMEM; - return NULL; - } - *param = ambient; - finish->ptr = param; - finish->ambient_fn = &dmnsn_ambient_finish_fn; - finish->free_fn = &free; - } + dmnsn_color *param = dmnsn_malloc(sizeof(dmnsn_color)); + *param = ambient; + + finish->ptr = param; + finish->ambient_fn = &dmnsn_ambient_finish_fn; + finish->free_fn = &free; + return finish; } -- cgit v1.2.3