From 098e8d8fba3d77fe206b51e0b28ef63aff060989 Mon Sep 17 00:00:00 2001 From: Dmitri Pal Date: Thu, 10 Jun 2010 11:53:54 -0400 Subject: [REFARRAY] Fixing the cleaup code It turned out that the array cleanup was assuming that the data always requires cleanup. In case of array of numbers it is a false assumtion. --- common/refarray/ref_array.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/common/refarray/ref_array.c b/common/refarray/ref_array.c index d02f9ae..a571804 100644 --- a/common/refarray/ref_array.c +++ b/common/refarray/ref_array.c @@ -341,8 +341,9 @@ int ref_array_replace(struct ref_array *ra, } /* Clear old element */ - ra->cb((unsigned char *)(ra->storage) + idx * ra->elsize, - REF_ARRAY_DELETE, ra->cb_data); + if (ra->cb) + ra->cb((unsigned char *)(ra->storage) + idx * ra->elsize, + REF_ARRAY_DELETE, ra->cb_data); /* Overwrite element */ memcpy((unsigned char *)(ra->storage) + idx * ra->elsize, @@ -375,8 +376,9 @@ int ref_array_remove(struct ref_array *ra, } /* Clear old element */ - ra->cb((unsigned char *)(ra->storage) + idx * ra->elsize, - REF_ARRAY_DELETE, ra->cb_data); + if (ra->cb) + ra->cb((unsigned char *)(ra->storage) + idx * ra->elsize, + REF_ARRAY_DELETE, ra->cb_data); /* Shift elements left */ for (i = idx + 1; i < ra->len; i++) { -- cgit