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>2012-12-11 19:10:19 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-12-11 19:10:19 +0400
commit71730f26d7c816854a471c9733ad4c10b88fd357 (patch)
tree0201ace6eac1fd2f48ae404bda6ea552cc1259d4 /source/blender/bmesh/intern/bmesh_construct.c
parent3520dd56e3894d2b5c825dc98cdd5d846b6756c0 (diff)
replace BLI_array_fixedstack_declare with() new macro BLI_array_alloca() which uses stack memory always and doesn't need to be freed explicitly.
Diffstat (limited to 'source/blender/bmesh/intern/bmesh_construct.c')
-rw-r--r--source/blender/bmesh/intern/bmesh_construct.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c
index 8b7fac1eacd..e12110b31ca 100644
--- a/source/blender/bmesh/intern/bmesh_construct.c
+++ b/source/blender/bmesh/intern/bmesh_construct.c
@@ -173,15 +173,17 @@ void BM_face_copy_shared(BMesh *bm, BMFace *f)
*/
BMFace *BM_face_create_ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, int len, const int create_flag)
{
- BMEdge **edges2 = NULL;
- BLI_array_staticdeclare(edges2, BM_DEFAULT_NGON_STACK_SIZE);
- BMVert **verts = NULL;
- BLI_array_staticdeclare(verts, BM_DEFAULT_NGON_STACK_SIZE);
+ BMEdge **edges2 = BLI_array_alloca_and_count(edges2, len);
+ BMVert **verts = BLI_array_alloca_and_count(verts, len + 1);
+ int e2_index = 0;
+ int v_index = 0;
+
BMFace *f = NULL;
BMEdge *e;
BMVert *v, *ev1, *ev2;
int i, /* j, */ v1found, reverse;
+
/* this code is hideous, yeek. I'll have to think about ways of
* cleaning it up. basically, it now combines the old BM_face_create_ngon
* _and_ the old bmesh_mf functions, so its kindof smashed together
@@ -207,14 +209,14 @@ BMFace *BM_face_create_ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, i
SWAP(BMVert *, ev1, ev2);
}
- BLI_array_append(verts, ev1);
+ verts[v_index++] = ev1;
v = ev2;
e = edges[0];
do {
BMEdge *e2 = e;
- BLI_array_append(verts, v);
- BLI_array_append(edges2, e);
+ verts[v_index++] = v;
+ edges2[e2_index++] = e;
/* we only flag the verts to check if they are in the face more then once */
BM_ELEM_API_FLAG_ENABLE(v, _FLAG_MV);
@@ -289,9 +291,6 @@ BMFace *BM_face_create_ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, i
BM_ELEM_API_FLAG_DISABLE(edges2[i], _FLAG_MF);
}
- BLI_array_free(verts);
- BLI_array_free(edges2);
-
return f;
err:
@@ -303,9 +302,6 @@ err:
}
}
- BLI_array_free(verts);
- BLI_array_free(edges2);
-
return NULL;
}