summaryrefslogtreecommitdiffstats
path: root/libdimension
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2009-05-10 04:19:33 +0000
committerTavian Barnes <tavianator@gmail.com>2009-05-10 04:19:33 +0000
commit95cf6ee35ab00cf2e2daf9a869ffda4216b95f8f (patch)
treea1cb8bcb845fe6b98024313ed355599448dd68ce /libdimension
parent62cdc4181f536384c70254f1e5d8ab311cff368d (diff)
downloaddimension-95cf6ee35ab00cf2e2daf9a869ffda4216b95f8f.tar.xz
Bail out on failed malloc in dmnsn_new_array.
Diffstat (limited to 'libdimension')
-rw-r--r--libdimension/array.c4
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);
}