diff options
author | Stephen Swaney <sswaney@centurytel.net> | 2004-05-16 03:10:37 +0400 |
---|---|---|
committer | Stephen Swaney <sswaney@centurytel.net> | 2004-05-16 03:10:37 +0400 |
commit | ae20f7a95e818175ea76cf4b93fb413416c10f73 (patch) | |
tree | c02b3336083764827bd1725ded42391f1648b95f /source/blender/python/api2_2x/vector.c | |
parent | 7b78a57c033d6aa6c6746e3502b9436b69a60cbc (diff) |
bugfix: #1206 Object.getBoundBox() was returning obdata coordinates.
fix memory leak in vector module. Memory allocated by vector constructor
was not being freed.
Diffstat (limited to 'source/blender/python/api2_2x/vector.c')
-rw-r--r-- | source/blender/python/api2_2x/vector.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/source/blender/python/api2_2x/vector.c b/source/blender/python/api2_2x/vector.c index 5ef10cdb9e6..a7e12a3d788 100644 --- a/source/blender/python/api2_2x/vector.c +++ b/source/blender/python/api2_2x/vector.c @@ -181,7 +181,11 @@ PyObject *Vector_Resize4D(VectorObject *self) static void Vector_dealloc(VectorObject *self) { - PyObject_DEL (self); + /* if we own this memory we must delete it */ + if( self->delete_pymem ) + PyMem_Free( self->vec ); + + PyObject_DEL (self); } static PyObject *Vector_getattr(VectorObject *self, char *name) @@ -573,6 +577,15 @@ PyTypeObject vector_Type = &Vector_SeqMethods, /*tp_as_sequence*/ }; + +/* + * create a Vector Object + * if vec arg is NULL + * allocate memory on python stack. + * initialize to zero in homogenous coords. + * size arg is number of floats to alloc. + */ + PyObject *newVectorObject(float *vec, int size) { VectorObject *self; @@ -588,8 +601,10 @@ PyObject *newVectorObject(float *vec, int size) self->vec[x] = 0.0f; } if(size == 4) self->vec[3] = 1.0f; + self->delete_pymem = 1; /* must free this alloc later */ }else{ self->vec = vec; + self->delete_pymem = 0; } self->size = size; |