diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-06-28 23:06:22 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-06-28 23:57:48 +0400 |
commit | f32079d4b9f0ee565dc4bb63a4ef25286f183d0e (patch) | |
tree | 10d24971269b58ebb42a35e3006bde9f5e21db5b /source/blender/bmesh | |
parent | 00c8a691e921e5e838b96e92290bd9901e1bf3c4 (diff) |
BLI_stackdefines
Bounds check the stack while debugging, also add STACK_PEEK
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_core.c | 4 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_queries.c | 8 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_bisect_plane.c | 2 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_connect.c | 4 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_removedoubles.c | 4 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_subdivide_edgering.c | 4 | ||||
-rw-r--r-- | source/blender/bmesh/tools/bmesh_bisect_plane.c | 4 |
7 files changed, 15 insertions, 15 deletions
diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c index c4dc9909185..1c93eccf8bd 100644 --- a/source/blender/bmesh/intern/bmesh_core.c +++ b/source/blender/bmesh/intern/bmesh_core.c @@ -2038,7 +2038,7 @@ void bmesh_vert_separate(BMesh *bm, BMVert *v, BMVert ***r_vout, int *r_vout_len BLI_smallhash_init_ex(&visithash, v_edgetot); - STACK_INIT(stack); + STACK_INIT(stack, v_edgetot); maxindex = 0; BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) { @@ -2109,7 +2109,7 @@ void bmesh_vert_separate(BMesh *bm, BMVert *v, BMVert ***r_vout, int *r_vout_len * by modifying data it loops over [#30632], this re-uses the 'stack' variable which is a bit * bad practice but save alloc'ing a new array - note, the comment above is useful, keep it * if you are tidying up code - campbell */ - STACK_INIT(stack); + STACK_INIT(stack, v_edgetot); BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) { if (l->v == v) { STACK_PUSH(stack, (BMEdge *)l); diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index d478ac07474..606e93d4a85 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -2068,7 +2068,7 @@ int BM_mesh_calc_face_groups(BMesh *bm, int *r_groups_array, int (**r_group_inde BMFace *f; int i; - STACK_INIT(group_array); + STACK_INIT(group_array, bm->totface); BLI_assert(((htype_step & ~(BM_VERT | BM_EDGE)) == 0) && (htype_step != 0)); @@ -2096,7 +2096,7 @@ int BM_mesh_calc_face_groups(BMesh *bm, int *r_groups_array, int (**r_group_inde BLI_assert(tot_touch < tot_faces); - STACK_INIT(stack); + STACK_INIT(stack, tot_faces); BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { if (BM_elem_flag_test(f, BM_ELEM_TAG) == false) { @@ -2224,7 +2224,7 @@ int BM_mesh_calc_edge_groups(BMesh *bm, int *r_groups_array, int (**r_group_inde BMEdge *e; int i; - STACK_INIT(group_array); + STACK_INIT(group_array, bm->totface); /* init the array */ BM_ITER_MESH_INDEX (e, &iter, bm, BM_EDGES_OF_MESH, i) { @@ -2250,7 +2250,7 @@ int BM_mesh_calc_edge_groups(BMesh *bm, int *r_groups_array, int (**r_group_inde BLI_assert(tot_touch < tot_edges); - STACK_INIT(stack); + STACK_INIT(stack, tot_edges); BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { if (BM_elem_flag_test(e, BM_ELEM_TAG) == false) { diff --git a/source/blender/bmesh/operators/bmo_bisect_plane.c b/source/blender/bmesh/operators/bmo_bisect_plane.c index 378cf405e16..bed1ea5cb94 100644 --- a/source/blender/bmesh/operators/bmo_bisect_plane.c +++ b/source/blender/bmesh/operators/bmo_bisect_plane.c @@ -90,7 +90,7 @@ void bmo_bisect_plane_exec(BMesh *bm, BMOperator *op) plane_outer[3] = plane[3] - dist; plane_inner[3] = plane[3] + dist; - STACK_INIT(vert_arr); + STACK_INIT(vert_arr, vert_arr_max); BMO_ITER (v, &siter, op->slots_in, "geom", BM_VERT) { if ((clear_outer && plane_point_side_v3(plane_outer, v->co) > 0.0f) || diff --git a/source/blender/bmesh/operators/bmo_connect.c b/source/blender/bmesh/operators/bmo_connect.c index 8b0033a9342..4cf6e82fc8e 100644 --- a/source/blender/bmesh/operators/bmo_connect.c +++ b/source/blender/bmesh/operators/bmo_connect.c @@ -52,8 +52,8 @@ static int bm_face_connect_verts(BMesh *bm, BMFace *f, const bool check_degenera BMLoop *l_last; unsigned int i; - STACK_INIT(loops_split); - STACK_INIT(verts_pair); + STACK_INIT(loops_split, f->len); + STACK_INIT(verts_pair, f->len); l_last = NULL; BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { diff --git a/source/blender/bmesh/operators/bmo_removedoubles.c b/source/blender/bmesh/operators/bmo_removedoubles.c index a17ab2133c1..814649c7dbf 100644 --- a/source/blender/bmesh/operators/bmo_removedoubles.c +++ b/source/blender/bmesh/operators/bmo_removedoubles.c @@ -92,8 +92,8 @@ static void remdoubles_createface(BMesh *bm, BMFace *f, BMOpSlot *slot_targetmap STACK_DECLARE(edges); STACK_DECLARE(loops); - STACK_INIT(edges); - STACK_INIT(loops); + STACK_INIT(edges, f->len); + STACK_INIT(loops, f->len); BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { BMVert *v1 = l->v; diff --git a/source/blender/bmesh/operators/bmo_subdivide_edgering.c b/source/blender/bmesh/operators/bmo_subdivide_edgering.c index ae1ff5a7389..e13a9df4474 100644 --- a/source/blender/bmesh/operators/bmo_subdivide_edgering.c +++ b/source/blender/bmesh/operators/bmo_subdivide_edgering.c @@ -970,8 +970,8 @@ static void bm_edgering_pair_subdiv(BMesh *bm, BMEdge *e; BMFace *f; - STACK_INIT(edges_ring_arr); - STACK_INIT(faces_ring_arr); + STACK_INIT(edges_ring_arr, stack_max); + STACK_INIT(faces_ring_arr, stack_max); bm_edgeloop_vert_tag(el_store_a, false); bm_edgeloop_vert_tag(el_store_b, true); diff --git a/source/blender/bmesh/tools/bmesh_bisect_plane.c b/source/blender/bmesh/tools/bmesh_bisect_plane.c index 0bd68e7a461..0ecb8066ac1 100644 --- a/source/blender/bmesh/tools/bmesh_bisect_plane.c +++ b/source/blender/bmesh/tools/bmesh_bisect_plane.c @@ -118,7 +118,7 @@ static void bm_face_bisect_verts(BMesh *bm, BMFace *f, const float plane[4], con BMLoop *l_iter, *l_first; bool use_dirs[3] = {false, false, false}; - STACK_INIT(vert_split_arr); + STACK_INIT(vert_split_arr, f_len_orig); l_first = BM_FACE_FIRST_LOOP(f); @@ -224,7 +224,7 @@ static void bm_face_bisect_verts(BMesh *bm, BMFace *f, const float plane[4], con * while not all that nice, typically there are < 5 resulting faces, * so its not _that_ bad. */ - STACK_INIT(face_split_arr); + STACK_INIT(face_split_arr, STACK_SIZE(vert_split_arr)); STACK_PUSH(face_split_arr, f); for (i = 0; i < STACK_SIZE(vert_split_arr) - 1; i++) { |