Skip to content

Commit 0db2607

Browse files
committed
fix memory leak
1 parent 0359e77 commit 0db2607

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

roboticstoolbox/core/fknm.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ static PyObject *fkine_all(PyObject *self, PyObject *args)
146146
}
147147
}
148148

149+
free(ret);
150+
149151
Py_RETURN_NONE;
150152
}
151153

@@ -591,6 +593,11 @@ void _jacobe(PyObject *links, int m, int n, npy_float64 *q, npy_float64 *etool,
591593
}
592594
}
593595
PyList_Reverse(links);
596+
597+
free(T);
598+
free(U);
599+
free(temp);
600+
free(ret);
594601
}
595602

596603
void _jacob0(PyObject *links, int m, int n, npy_float64 *q, npy_float64 *etool, npy_float64 *tool, npy_float64 *J)
@@ -693,6 +700,12 @@ void _jacob0(PyObject *links, int m, int n, npy_float64 *q, npy_float64 *etool,
693700
copy(temp, U);
694701
}
695702
}
703+
704+
free(T);
705+
free(U);
706+
free(temp);
707+
free(ret);
708+
free(invU);
696709
}
697710

698711
void _fkine(PyObject *links, int n, npy_float64 *q, npy_float64 *etool, npy_float64 *tool, npy_float64 *ret)
@@ -725,6 +738,9 @@ void _fkine(PyObject *links, int n, npy_float64 *q, npy_float64 *etool, npy_floa
725738
mult(current, etool, ret);
726739
copy(ret, current);
727740
mult(current, tool, ret);
741+
742+
free(temp);
743+
free(current);
728744
}
729745

730746
void A(Link *link, npy_float64 *ret, double eta)
@@ -748,6 +764,7 @@ void A(Link *link, npy_float64 *ret, double eta)
748764

749765
// Multiply ret = A * v
750766
mult(link->A, v, ret);
767+
free(v);
751768
}
752769

753770
void copy(npy_float64 *A, npy_float64 *B)
@@ -1074,6 +1091,7 @@ int _inv(npy_float64 *m, npy_float64 *invOut)
10741091
for (i = 0; i < 16; i++)
10751092
invOut[i] = inv[i] * det;
10761093

1094+
free(inv);
10771095
return 1;
10781096
}
10791097

0 commit comments

Comments
 (0)