@@ -146,6 +146,7 @@ static PyObject *fkine_all(PyObject *self, PyObject *args)
146
146
}
147
147
}
148
148
149
+ Py_DECREF (iter_links );
149
150
free (ret );
150
151
151
152
Py_RETURN_NONE ;
@@ -328,6 +329,11 @@ static PyObject *link_init(PyObject *self, PyObject *args)
328
329
link -> op = tz ;
329
330
}
330
331
332
+ Py_DECREF (iter_base );
333
+ Py_DECREF (iter_wT );
334
+ Py_DECREF (iter_sT );
335
+ Py_DECREF (iter_sq );
336
+
331
337
ret = PyCapsule_New (link , "Link" , NULL );
332
338
return ret ;
333
339
}
@@ -380,6 +386,20 @@ static PyObject *link_update(PyObject *self, PyObject *args)
380
386
iter_sT = PyObject_GetIter (py_shape_sT );
381
387
iter_sq = PyObject_GetIter (py_shape_sq );
382
388
389
+ if (link -> shape_base != 0 )
390
+ free (link -> shape_base );
391
+ if (link -> shape_wT != 0 )
392
+ free (link -> shape_wT );
393
+ if (link -> shape_sT != 0 )
394
+ free (link -> shape_sT );
395
+ if (link -> shape_sq != 0 )
396
+ free (link -> shape_sq );
397
+
398
+ link -> shape_base = 0 ;
399
+ link -> shape_wT = 0 ;
400
+ link -> shape_sT = 0 ;
401
+ link -> shape_sq = 0 ;
402
+
383
403
link -> shape_base = (npy_float64 * * )PyMem_RawCalloc (n_shapes , sizeof (npy_float64 ));
384
404
link -> shape_wT = (npy_float64 * * )PyMem_RawCalloc (n_shapes , sizeof (npy_float64 ));
385
405
link -> shape_sT = (npy_float64 * * )PyMem_RawCalloc (n_shapes , sizeof (npy_float64 ));
@@ -434,6 +454,11 @@ static PyObject *link_update(PyObject *self, PyObject *args)
434
454
link -> parent = parent ;
435
455
link -> n_shapes = n_shapes ;
436
456
457
+ Py_DECREF (iter_base );
458
+ Py_DECREF (iter_wT );
459
+ Py_DECREF (iter_sT );
460
+ Py_DECREF (iter_sq );
461
+
437
462
Py_RETURN_NONE ;
438
463
}
439
464
@@ -594,6 +619,8 @@ void _jacobe(PyObject *links, int m, int n, npy_float64 *q, npy_float64 *etool,
594
619
}
595
620
PyList_Reverse (links );
596
621
622
+ Py_DECREF (iter_links );
623
+
597
624
free (T );
598
625
free (U );
599
626
free (temp );
@@ -701,6 +728,8 @@ void _jacob0(PyObject *links, int m, int n, npy_float64 *q, npy_float64 *etool,
701
728
}
702
729
}
703
730
731
+ Py_DECREF (iter_links );
732
+
704
733
free (T );
705
734
free (U );
706
735
free (temp );
@@ -739,6 +768,8 @@ void _fkine(PyObject *links, int n, npy_float64 *q, npy_float64 *etool, npy_floa
739
768
copy (ret , current );
740
769
mult (current , tool , ret );
741
770
771
+ Py_DECREF (iter_links );
772
+
742
773
free (temp );
743
774
free (current );
744
775
}
0 commit comments