diff options
author | Tavian Barnes <tavianator@gmail.com> | 2010-04-07 14:26:15 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2010-04-07 14:34:52 -0400 |
commit | 2b087cb45ae91f90492a935625570d7d42ee3ecb (patch) | |
tree | a464213b08d04c8c91c8879a84e534f895c84378 /libdimension/point_light.c | |
parent | 7d6663eeb68bf9d0a3dff86128827c0c1d85df69 (diff) | |
download | dimension-2b087cb45ae91f90492a935625570d7d42ee3ecb.tar.xz |
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.
Diffstat (limited to 'libdimension/point_light.c')
-rw-r--r-- | libdimension/point_light.c | 22 |
1 files changed, 8 insertions, 14 deletions
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; } |