diff options
author | Campbell Barton <ideasman42@gmail.com> | 2006-07-02 14:37:24 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2006-07-02 14:37:24 +0400 |
commit | f2d80ee097f070c5191324a46db8e698e979fc35 (patch) | |
tree | 41491388c1e72531a30a89c7900a7a4380835add /source/blender/python/api2_2x/Mathutils.c | |
parent | ae59f05c85156e562ec8edcf0e87484862a0a630 (diff) |
wasnt decref'ing items I got from PySequence_GetItem for PolyFill or ob.join() fixed and tested, memory dosent increse when used in a large loop.
Diffstat (limited to 'source/blender/python/api2_2x/Mathutils.c')
-rw-r--r-- | source/blender/python/api2_2x/Mathutils.c | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/source/blender/python/api2_2x/Mathutils.c b/source/blender/python/api2_2x/Mathutils.c index 7188a999cd2..2b78fe21c11 100644 --- a/source/blender/python/api2_2x/Mathutils.c +++ b/source/blender/python/api2_2x/Mathutils.c @@ -1571,34 +1571,37 @@ PyObject *M_Mathutils_PolyFill( PyObject * self, PyObject * args ) for( i = 0; i < len_polylines; ++i ) { polyLine= PySequence_GetItem( polyLineList, i ); - if (EXPP_check_sequence_consistency( polyLine, &vector_Type ) != 1) - return EXPP_ReturnPyObjError( PyExc_TypeError, - "expected a list of poly lines" ); - len_polypoints= PySequence_Size( polyLine ); - - dl= MEM_callocN(sizeof(DispList), "poly disp"); - BLI_addtail(&dispbase, dl); - dl->type= DL_INDEX3; - dl->nr= len_polypoints; - dl->type= DL_POLY; - dl->parts= 1; /* no faces, 1 edge loop */ - dl->col= 0; /* no material */ - dl->verts= fp= MEM_callocN( sizeof(float)*3*len_polypoints, "dl verts"); - dl->index= MEM_callocN(sizeof(int)*3*len_polypoints, "dl index"); - - for( index = 0; index<len_polypoints; ++index, fp+=3) { - polyVec= PySequence_GetItem( polyLine, index ); + if (len_polypoints>2) { /* dont bother adding edges as polylines */ + if (EXPP_check_sequence_consistency( polyLine, &vector_Type ) != 1) + return EXPP_ReturnPyObjError( PyExc_TypeError, + "expected a list of poly lines" ); - fp[0] = ((VectorObject *)polyVec)->vec[0]; - fp[1] = ((VectorObject *)polyVec)->vec[1]; - if( ((VectorObject *)polyVec)->size > 2 ) - fp[2] = ((VectorObject *)polyVec)->vec[2]; - else - fp[2]= 0.0f; /* if its a 2d vector then set the z to be zero */ + dl= MEM_callocN(sizeof(DispList), "poly disp"); + BLI_addtail(&dispbase, dl); + dl->type= DL_INDEX3; + dl->nr= len_polypoints; + dl->type= DL_POLY; + dl->parts= 1; /* no faces, 1 edge loop */ + dl->col= 0; /* no material */ + dl->verts= fp= MEM_callocN( sizeof(float)*3*len_polypoints, "dl verts"); + dl->index= MEM_callocN(sizeof(int)*3*len_polypoints, "dl index"); - totpoints++; + for( index = 0; index<len_polypoints; ++index, fp+=3) { + polyVec= PySequence_GetItem( polyLine, index ); + + fp[0] = ((VectorObject *)polyVec)->vec[0]; + fp[1] = ((VectorObject *)polyVec)->vec[1]; + if( ((VectorObject *)polyVec)->size > 2 ) + fp[2] = ((VectorObject *)polyVec)->vec[2]; + else + fp[2]= 0.0f; /* if its a 2d vector then set the z to be zero */ + + totpoints++; + Py_DECREF(polyVec); + } } + Py_DECREF(polyLine); } if (totpoints) { |