From 36bfe9582900206a8cb13bce5778cc12f0126b40 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Thu, 27 Feb 2014 14:12:44 +0200 Subject: [PATCH] Add check for array destructor * Check if array destructor is not null before calling. --- src/array.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/array.c b/src/array.c index 83863d1df..7d6cf69e8 100644 --- a/src/array.c +++ b/src/array.c @@ -57,7 +57,9 @@ void *array_at(struct array *array, int idx) void array_erase(struct array *array, int idx) { - array->dtor(array->data[idx]); + if (array->dtor) { + array->dtor(array->data[idx]); + } memmove(array->data+idx, array->data+idx+1, (array->index-idx-1) * sizeof(void*)); array->index--; } @@ -65,7 +67,9 @@ void array_erase(struct array *array, int idx) void array_resize(struct array *array, int idx) { while (array->index > idx) { - array->dtor(array->data[array->index-1]); + if (array->dtor != NULL) { + array->dtor(array->data[array->index-1]); + } array->index--; } }