diff options
author | Tavian Barnes <tavianator@gmail.com> | 2009-05-10 04:19:33 +0000 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2009-05-10 04:19:33 +0000 |
commit | 95cf6ee35ab00cf2e2daf9a869ffda4216b95f8f (patch) | |
tree | a1cb8bcb845fe6b98024313ed355599448dd68ce /libdimension | |
parent | 62cdc4181f536384c70254f1e5d8ab311cff368d (diff) | |
download | dimension-95cf6ee35ab00cf2e2daf9a869ffda4216b95f8f.tar.xz |
Bail out on failed malloc in dmnsn_new_array.
Diffstat (limited to 'libdimension')
-rw-r--r-- | libdimension/array.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/libdimension/array.c b/libdimension/array.c index b095654..97ce716 100644 --- a/libdimension/array.c +++ b/libdimension/array.c @@ -32,8 +32,7 @@ dmnsn_new_array(size_t obj_size) array->ptr = malloc(array->capacity*array->obj_size); if (!array->ptr) { - free(array); - return NULL; + dmnsn_error(DMNSN_SEVERITY_HIGH, "Array allocation failed."); } } @@ -60,7 +59,6 @@ dmnsn_array_get(const dmnsn_array *array, size_t i, void *obj) if (i >= array->length) { dmnsn_error(DMNSN_SEVERITY_HIGH, "Array index out of bounds."); } - memcpy(obj, array->ptr + array->obj_size*i, array->obj_size); } |