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/point_light.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'libdimension/point_light.c') diff --git a/libdimension/point_light.c b/libdimension/point_light.c index 1ca3c96..02ab2ea 100644 --- a/libdimension/point_light.c +++ b/libdimension/point_light.c @@ -35,20 +35,14 @@ dmnsn_light * dmnsn_new_point_light(dmnsn_vector x0, dmnsn_color color) { dmnsn_light *light = dmnsn_new_light(); - if (light) { - /* Allocate room for the transformation matrix */ - dmnsn_color *ptr = malloc(sizeof(dmnsn_color)); - if (!ptr) { - dmnsn_delete_light(light); - errno = ENOMEM; - return NULL; - } - *ptr = color; - light->x0 = x0; - light->light_fn = &dmnsn_point_light_fn; - light->free_fn = &free; - light->ptr = ptr; - } + dmnsn_color *ptr = dmnsn_malloc(sizeof(dmnsn_color)); + *ptr = color; + + light->x0 = x0; + light->light_fn = &dmnsn_point_light_fn; + light->free_fn = &free; + light->ptr = ptr; + return light; } -- cgit v1.2.3