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/light.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'libdimension/light.c') diff --git a/libdimension/light.c b/libdimension/light.c index cc2c961..8be90e0 100644 --- a/libdimension/light.c +++ b/libdimension/light.c @@ -20,20 +20,15 @@ #include "dimension.h" #include -#include /* For malloc */ /* Allocate a new dummy light */ dmnsn_light * dmnsn_new_light() { - dmnsn_light *light = malloc(sizeof(dmnsn_light)); - if (light) { - light->light_fn = NULL; - light->free_fn = NULL; - light->ptr = NULL; - } else { - errno = ENOMEM; - } + dmnsn_light *light = dmnsn_malloc(sizeof(dmnsn_light)); + light->light_fn = NULL; + light->free_fn = NULL; + light->ptr = NULL; return light; } -- cgit v1.2.3