Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-05-13 17:44:20 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-05-13 17:44:20 +0400
commit281c1565b94948ad1d5339b9e8bf1157598aa199 (patch)
tree069436141bea29f1290794e30ddd1a86013a5c3b /source/blender/bmesh/intern/bmesh_iterators.c
parent682da3ac98603f32deadb7a531f460f62de84e1c (diff)
remove BLI_array use in bmesh mirror, add BMO_iter_as_arrayN() function.
Diffstat (limited to 'source/blender/bmesh/intern/bmesh_iterators.c')
-rw-r--r--source/blender/bmesh/intern/bmesh_iterators.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/source/blender/bmesh/intern/bmesh_iterators.c b/source/blender/bmesh/intern/bmesh_iterators.c
index 89348f23b9d..cd66617bbf9 100644
--- a/source/blender/bmesh/intern/bmesh_iterators.c
+++ b/source/blender/bmesh/intern/bmesh_iterators.c
@@ -186,6 +186,42 @@ void *BM_iter_as_arrayN(BMesh *bm, const char itype, void *data, int *r_len,
}
}
+void *BMO_iter_as_arrayN(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char restrictmask,
+ int *r_len,
+ /* optional args to avoid an alloc (normally stack array) */
+ void **stack_array, int stack_array_size)
+{
+ BMOIter iter;
+ BMElem *ele;
+ int count = BMO_slot_buffer_count(slot_args, slot_name);
+
+ BLI_assert(stack_array_size == 0 || (stack_array_size && stack_array));
+
+ if ((ele = BMO_iter_new(&iter, slot_args, slot_name, restrictmask)) && count > 0) {
+ BMElem **array = count > stack_array_size ?
+ MEM_mallocN(sizeof(ele) * count, __func__) :
+ stack_array;
+ int i = 0;
+
+ do {
+ array[i++] = ele;
+ } while ((ele = BMO_iter_step(&iter)));
+ BLI_assert(i <= count);
+
+ if (i != count) {
+ if ((void **)array != stack_array) {
+ array = MEM_reallocN(array, sizeof(ele) * i);
+ }
+ }
+ *r_len = i;
+ return array;
+ }
+ else {
+ *r_len = 0;
+ return NULL;
+ }
+}
+
/**
* \brief Elem Iter Flag Count
*