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>2006-07-02 14:37:24 +0400
committerCampbell Barton <ideasman42@gmail.com>2006-07-02 14:37:24 +0400
commitf2d80ee097f070c5191324a46db8e698e979fc35 (patch)
tree41491388c1e72531a30a89c7900a7a4380835add /source/blender/python
parentae59f05c85156e562ec8edcf0e87484862a0a630 (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')
-rw-r--r--source/blender/python/api2_2x/Mathutils.c51
-rw-r--r--source/blender/python/api2_2x/Object.c1
2 files changed, 28 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) {
diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c
index 221b9c724a0..d12dfa4d16e 100644
--- a/source/blender/python/api2_2x/Object.c
+++ b/source/blender/python/api2_2x/Object.c
@@ -2077,6 +2077,7 @@ static PyObject *Object_join( BPy_Object * self, PyObject * args )
} else {
/* List item is an object, is it the same type? */
child = ( Object * ) Object_FromPyObject( py_child );
+ Py_DECREF (py_child);
if (parent->type == child->type) {
if (object_in_scene( child, G.scene )==NULL) {