summaryrefslogtreecommitdiff
path: root/mysys/array.c
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2013-10-29 15:08:44 +0100
committerSergei Golubchik <sergii@pisem.net>2013-10-29 15:08:44 +0100
commit0fdb3bcfdbfa5d7cad28adc1c0f7c0958cdab2e0 (patch)
tree7d6a1d36b975e2b1bb8d9ffd3b7511ec0694349e /mysys/array.c
parent7dc48ae327ad27205dffe0cec16b445d01529f84 (diff)
parentfef416699009b78366d9eec937c01822b531f518 (diff)
downloadmariadb-git-0fdb3bcfdbfa5d7cad28adc1c0f7c0958cdab2e0.tar.gz
10.0-base merge (roles)
Diffstat (limited to 'mysys/array.c')
-rw-r--r--mysys/array.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/mysys/array.c b/mysys/array.c
index cf377f77676..e92c5b45e67 100644
--- a/mysys/array.c
+++ b/mysys/array.c
@@ -321,7 +321,24 @@ void delete_dynamic_element(DYNAMIC_ARRAY *array, uint idx)
(array->elements-idx)*array->size_of_element);
}
+/*
+ Wrapper around delete_dynamic, calling a FREE function on every
+ element, before releasing the memory
+ SYNOPSIS
+ delete_dynamic_with_callback()
+ array
+ f The function to be called on every element before
+ deleting the array;
+*/
+void delete_dynamic_with_callback(DYNAMIC_ARRAY *array, FREE_FUNC f) {
+ uint i;
+ char *ptr= (char*) array->buffer;
+ for (i= 0; i < array->elements; i++, ptr+= array->size_of_element) {
+ f(ptr);
+ }
+ delete_dynamic(array);
+}
/*
Free unused memory