summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitri Pal <dpal@redhat.com>2010-06-10 11:53:54 -0400
committerStephen Gallagher <sgallagh@redhat.com>2010-09-22 14:57:52 -0400
commit252be01e3972f0bfa01b5ad562a4c95d5fbf0039 (patch)
treedb29c5650bdd62554c31cd97b4a467b650c02d88
parente65ef66621b6d59580018f6ecf1f9bffacc27372 (diff)
downloadding-libs-252be01e3972f0bfa01b5ad562a4c95d5fbf0039.tar.gz
ding-libs-252be01e3972f0bfa01b5ad562a4c95d5fbf0039.tar.xz
ding-libs-252be01e3972f0bfa01b5ad562a4c95d5fbf0039.zip
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.
-rw-r--r--refarray/ref_array.c10
1 files 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++) {