From 252be01e3972f0bfa01b5ad562a4c95d5fbf0039 Mon Sep 17 00:00:00 2001 From: Dmitri Pal Date: Thu, 10 Jun 2010 11:53:54 -0400 Subject: 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. --- refarray/ref_array.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/refarray/ref_array.c b/refarray/ref_array.c index d02f9ae..a571804 100644 --- a/refarray/ref_array.c +++ b/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