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:
authorMartin Poirier <theeth@yahoo.com>2005-06-17 08:40:07 +0400
committerMartin Poirier <theeth@yahoo.com>2005-06-17 08:40:07 +0400
commit2a640f03cd71cf96b817a37cdd72f8e27f3f732a (patch)
treec47d848a992c7b4922f8ff79e088acf07b1f42a3 /source/blender/python/api2_2x/CurNurb.c
parente382d8ad4a97183700165d3b0b66a0e94814a34a (diff)
My patch to BPy's curve module (applied by stivs) had a small mem leak. Fixing now.
Diffstat (limited to 'source/blender/python/api2_2x/CurNurb.c')
-rw-r--r--source/blender/python/api2_2x/CurNurb.c41
1 files changed, 29 insertions, 12 deletions
diff --git a/source/blender/python/api2_2x/CurNurb.c b/source/blender/python/api2_2x/CurNurb.c
index ce31f348c9f..bb69ef6f8b9 100644
--- a/source/blender/python/api2_2x/CurNurb.c
+++ b/source/blender/python/api2_2x/CurNurb.c
@@ -406,10 +406,10 @@ static PyObject *CurNurb_getType( BPy_CurNurb * self )
static PyObject *CurNurb_setType( BPy_CurNurb * self, PyObject * args )
{
Nurb *nurb = self->nurb;
- int type;
+ short type;
/* parameter type checking */
- if( !PyArg_ParseTuple( args, "i", &type ) )
+ if( !PyArg_ParseTuple( args, "h", &type ) )
return EXPP_ReturnPyObjError
( PyExc_TypeError, "expected integer argument" );
@@ -536,15 +536,24 @@ PyObject *CurNurb_appendPointToNurb( Nurb * nurb, PyObject * args )
sizeof( BPoint ) );
for( i = 0; i < 4; ++i ) {
- float tmpx =
- ( float ) PyFloat_AsDouble
- ( PySequence_GetItem( pyOb, i ) );
- nurb->bp[npoints].vec[i] = tmpx;
+ PyObject *item = PySequence_GetItem( pyOb, i );
+ if (item == NULL)
+ return NULL;
+
+
+ nurb->bp[npoints].vec[i] = ( float ) PyFloat_AsDouble( item );
+ Py_DECREF( item );
}
if (size == 5) {
- nurb->bp[npoints].alfa = (float)PyFloat_AsDouble( PySequence_GetItem( pyOb, 4 ) );
+ PyObject *item = PySequence_GetItem( pyOb, i );
+
+ if (item == NULL)
+ return NULL;
+
+ nurb->bp[npoints].alfa = ( float ) PyFloat_AsDouble( item );
+ Py_DECREF( item );
}
else {
nurb->bp[npoints].alfa = 0.0f;
@@ -890,15 +899,23 @@ static int CurNurb_setPoint( BPy_CurNurb * self, int index, PyObject * pyOb )
/* copy x, y, z, w */
for( i = 0; i < 4; ++i ) {
- float tmpx =
- ( float ) PyFloat_AsDouble
- ( PySequence_GetItem( pyOb, i ) );
- nurb->bp[index].vec[i] = tmpx;
+ PyObject *item = PySequence_GetItem( pyOb, i );
+ if (item == NULL)
+ return -1;
+
+ nurb->bp[index].vec[i] = ( float ) PyFloat_AsDouble( item );
+ Py_DECREF( item );
}
if (size == 5) { /* set tilt, if present */
- nurb->bp[index].alfa = (float)PyFloat_AsDouble( PySequence_GetItem( pyOb, 4 ) );
+ PyObject *item = PySequence_GetItem( pyOb, i );
+
+ if (item == NULL)
+ return -1;
+
+ nurb->bp[index].alfa = ( float ) PyFloat_AsDouble( item );
+ Py_DECREF( item );
}
else { /* if not, set default */
nurb->bp[index].alfa = 0.0f;