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-27 06:33:54 +0400
committerCampbell Barton <ideasman42@gmail.com>2006-07-27 06:33:54 +0400
commit403b62fbcf7480596f669029325b64eb369fe203 (patch)
tree1ef7efffa411bf2bc0f85a8e8011cd9d2400e54a /source/blender/python/api2_2x/matrix.c
parentb227c98c443b2106df37a9ebeb04dcd50d6f2e49 (diff)
matrix .inverted() and .transposed() didnt work because the matrix was wrongly copied.
2 more memory leaks in matrix multiplication fixed.
Diffstat (limited to 'source/blender/python/api2_2x/matrix.c')
-rw-r--r--source/blender/python/api2_2x/matrix.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/source/blender/python/api2_2x/matrix.c b/source/blender/python/api2_2x/matrix.c
index f819f3294e0..a36f79a7660 100644
--- a/source/blender/python/api2_2x/matrix.c
+++ b/source/blender/python/api2_2x/matrix.c
@@ -273,10 +273,11 @@ PyObject *Matrix_Invert(MatrixObject * self)
/*---------------------------Matrix.inverted() ------------------*/
PyObject *Matrix_Inverted(MatrixObject * self)
{
- MatrixObject *mat;
- mat= (MatrixObject*)newMatrixObject(self->matrix, self->rowSize, self->colSize, Py_NEW);
- Matrix_Invert(mat);
- return (PyObject*)mat;
+ MatrixObject *pymat;
+ /*copy the matrix*/
+ pymat= (MatrixObject*)newMatrixObject((float (*))*self->matrix, self->rowSize, self->colSize, Py_NEW);
+ Matrix_Invert(pymat);
+ return (PyObject*)pymat;
}
/*---------------------------Matrix.determinant() ----------------*/
@@ -331,10 +332,11 @@ PyObject *Matrix_Transpose(MatrixObject * self)
/*---------------------------Matrix.transposed() ------------------*/
PyObject *Matrix_Transposed(MatrixObject * self)
{
- MatrixObject *mat;
- mat= (MatrixObject*)newMatrixObject(self->matrix, self->rowSize, self->colSize, Py_NEW);
- Matrix_Transpose(mat);
- return (PyObject*)mat;
+ MatrixObject *pymat;
+ /*copy the matrix*/
+ pymat= (MatrixObject*)newMatrixObject((float (*))*self->matrix, self->rowSize, self->colSize, Py_NEW);
+ Matrix_Transpose(pymat);
+ return (PyObject*)pymat;
}
@@ -726,6 +728,7 @@ static PyObject *Matrix_mul(PyObject * m1, PyObject * m2)
}
scalar = (float)PyFloat_AS_DOUBLE(f);
+ Py_DECREF(f);
for(x = 0; x < mat2->rowSize; x++) {
for(y = 0; y < mat2->colSize; y++) {
mat[((x * mat2->colSize) + y)] = scalar * mat2->matrix[x][y];
@@ -750,6 +753,7 @@ static PyObject *Matrix_mul(PyObject * m1, PyObject * m2)
}
scalar = (float)PyFloat_AS_DOUBLE(f);
+ Py_DECREF(f);
for(x = 0; x < mat1->rowSize; x++) {
for(y = 0; y < mat1->colSize; y++) {
mat[((x * mat1->colSize) + y)] = scalar * mat1->matrix[x][y];
@@ -974,4 +978,4 @@ PyObject *newMatrixObject(float *mat, int rowSize, int colSize, int type)
return NULL;
}
return (PyObject *) self;
-}
+} \ No newline at end of file