diff --git a/source/blender/blenkernel/BKE_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h index 2f092d3a5a3..0eccf0cf56b 100644 --- a/source/blender/blenkernel/BKE_utildefines.h +++ b/source/blender/blenkernel/BKE_utildefines.h @@ -215,12 +215,21 @@ for (i=0; i<10; i++) { arr[i] = something; } V_FREE(arr); + +arrays are buffered, using double-buffering (so on each reallocation, +the array size is doubled). supposedly this should give good Big Oh +behaviour, though it may not be the best in practice. */ #define V_DECLARE(vec) int _##vec##_count=0; void *_##vec##_tmp + +/*this returns the entire size of the array, including any buffering.*/ #define V_SIZE(vec) ((vec)==NULL ? 0 : MEM_allocN_len(vec) / sizeof(*vec)) + +/*this returns the logical size of the array, not including buffering.*/ #define V_COUNT(vec) _##vec##_count -#define MSTR(s) #s + +/*grow the array by one. zeroes the new elements.*/ #define V_GROW(vec) \ V_SIZE(vec) > _##vec##_count ? _##vec##_count++ : \ ((_##vec##_tmp = MEM_callocN(sizeof(*vec)*(_##vec##_count*2+2), #vec " " __FILE__ " ")),\ @@ -229,8 +238,9 @@ V_FREE(arr); (vec = _##vec##_tmp),\ _##vec##_count++) -//(vec) ? WMEM_freeN(vec), 1 : 0 #define V_FREE(vec) if (vec) MEM_freeN(vec); +/*resets the logical size of an array to zero, but doesn't + free the memory.*/ #define V_RESET(vec) _##vec##_count=0 #endif diff --git a/source/blender/bmesh/operators/subdivideop.c b/source/blender/bmesh/operators/subdivideop.c index 70f17e20553..c94381a3f20 100644 --- a/source/blender/bmesh/operators/subdivideop.c +++ b/source/blender/bmesh/operators/subdivideop.c @@ -691,11 +691,14 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op) j++; } + for (j=0; jlen; j++) { + V_GROW(verts); + } + j = 0; for (nl=BMIter_New(&liter, bmesh, BM_LOOPS_OF_FACE, face); nl; nl=BMIter_Step(&liter)) { b = (j-a+face->len) % face->len; - V_GROW(verts); verts[b] = nl->v; j += 1; } diff --git a/source/blender/bmesh/operators/triangulateop.c b/source/blender/bmesh/operators/triangulateop.c index c7e36b27836..b08c633661d 100644 --- a/source/blender/bmesh/operators/triangulateop.c +++ b/source/blender/bmesh/operators/triangulateop.c @@ -24,10 +24,6 @@ void triangulate_exec(BMesh *bmesh, BMOperator *op) for (i=0; ilen; i++) { face = ((BMFace**)finput->data.p)[i]; - /*HACK! need to discuss with Briggs why the function takes an - externally-allocated array of vert coordinates in the first place.*/ - //if (face->len > 400) projverts = MEM_callocN(sizeof(float)*3*face->len, "projverts"); - //else projverts = projectverts; if (lastlen < face->len) { V_RESET(projectverts); for (lastlen=0; lastlenlen; lastlen++) {