Commit d54d8577 authored by Manuel Günther's avatar Manuel Günther

Fixed some memory leaks

parent 9bcc54db
......@@ -81,7 +81,6 @@ PyObject* PyBobIpBase_histogram(PyObject*, PyObject* args, PyObject* kwargs) {
} else {
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&O&", kwlist2, &PyBlitzArray_Converter, &src, &PyBlitzArray_OutputConverter, &hist)) return 0;
}
// get the number of bins
src_ = make_safe(src);
hist_ = make_xsafe(hist);
break;
......@@ -95,6 +94,8 @@ PyObject* PyBobIpBase_histogram(PyObject*, PyObject* args, PyObject* kwargs) {
} else {
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&OO&", kwlist4, &PyBlitzArray_Converter, &src, &min_max, &PyBlitzArray_OutputConverter, &hist)) return 0;
}
src_ = make_safe(src);
hist_ = make_xsafe(hist);
break;
}
default:
......
......@@ -352,6 +352,7 @@ static PyObject* PyBobIpBaseDCTFeatures_outputShape(PyBobIpBaseDCTFeaturesObject
blitz::TinyVector<int,2> shape;
PyObject* flat = 0; // is_integral_image
PyObject* k = Py_BuildValue("s", kwlist2[0]);
auto k_ = make_safe(k);
if (
(kwargs && PyDict_Contains(kwargs, k)) ||
(args && (PyTuple_Check(PyTuple_GetItem(args, 0)) || PyList_Check(PyTuple_GetItem(args, 0))))
......
......@@ -260,7 +260,7 @@ PyObject* PyBobIpBaseFaceEyesNorm_getGeomNorm(PyBobIpBaseFaceEyesNormObject* sel
BOB_TRY
PyBobIpBaseGeomNormObject* geomNorm = (PyBobIpBaseGeomNormObject*)PyBobIpBaseGeomNorm_Type.tp_alloc(&PyBobIpBaseGeomNorm_Type, 0);
geomNorm->cxx = self->cxx->getGeomNorm();
return Py_BuildValue("O", geomNorm);
return Py_BuildValue("N", geomNorm);
BOB_CATCH_MEMBER("geom_norm could not be read", 0)
}
......
......@@ -725,7 +725,7 @@ static PyObject* PyBobIpBaseGaussianScaleSpace_getGaussian(PyBobIpBaseGaussianSc
PyBobIpBaseGaussianObject* gaussian = (PyBobIpBaseGaussianObject*)PyBobIpBaseGaussian_Type.tp_alloc(&PyBobIpBaseGaussian_Type, 0);
gaussian->cxx = self->cxx->getGaussian(index);
return Py_BuildValue("O", gaussian);
return Py_BuildValue("N", gaussian);
BOB_CATCH_MEMBER("cannot get Gaussian", 0)
}
......@@ -773,6 +773,7 @@ static PyObject* _allocate(PyBobIpBaseGaussianScaleSpaceObject* self){
const blitz::TinyVector<int,3> shape = self->cxx->getOutputShape(i);
Py_ssize_t o[] = {shape[0], shape[1], shape[2]};
PyBlitzArrayObject* array = (PyBlitzArrayObject*)PyBlitzArray_SimpleNew(NPY_FLOAT64, 3, o);
auto array_ = make_safe(array);
PyList_SET_ITEM(list, i, PyBlitzArray_AsNumpyArray(array, 0));
}
......
......@@ -283,6 +283,7 @@ static int PyBobIpBaseGLCM_init(PyBobIpBaseGLCMObject* self, PyObject* args, PyO
}
static void PyBobIpBaseGLCM_delete(PyBobIpBaseGLCMObject* self) {
self->prop.reset();
self->cxx.reset();
Py_TYPE(self)->tp_free((PyObject*)self);
}
......@@ -751,7 +752,7 @@ static PyObject* PyBobIpBaseGLCM_propertiesByName(PyBobIpBaseGLCMObject* self, P
case GLCMProperty::GLCMProperty_Count: return 0; // cannot happen
}
// set list item
PyList_SET_ITEM(result, i, Py_BuildValue("O", PyBlitzArray_AsNumpyArray(values, 0)));
PyList_SET_ITEM(result, i, Py_BuildValue("N", PyBlitzArray_AsNumpyArray(values, 0)));
}
return Py_BuildValue("O", result);
......
......@@ -781,6 +781,7 @@ static PyObject* PyBobIpBaseLBP_getShape(PyBobIpBaseLBPObject* self, PyObject* a
blitz::TinyVector<int,2> shape;
PyObject* iii = 0; // is_integral_image
PyObject* k = Py_BuildValue("s", kwlist2[0]);
auto k_ = make_safe(k);
if (
(kwargs && PyDict_Contains(kwargs, k)) ||
(args && PyTuple_Size(args) && (PyTuple_Check(PyTuple_GetItem(args, 0)) || PyList_Check(PyTuple_GetItem(args, 0))))
......
......@@ -98,7 +98,7 @@ PyObject* PyBobIpBaseLBPTop_getXY(PyBobIpBaseLBPTopObject* self, void*){
BOB_TRY
PyBobIpBaseLBPObject* lbp = (PyBobIpBaseLBPObject*)PyBobIpBaseLBP_Type.tp_alloc(&PyBobIpBaseLBP_Type, 0);
lbp->cxx = self->cxx->getXY();
return Py_BuildValue("O", lbp);
return Py_BuildValue("N", lbp);
BOB_CATCH_MEMBER("xy could not be read", 0)
}
......@@ -111,7 +111,7 @@ PyObject* PyBobIpBaseLBPTop_getXT(PyBobIpBaseLBPTopObject* self, void*){
BOB_TRY
PyBobIpBaseLBPObject* lbp = (PyBobIpBaseLBPObject*)PyBobIpBaseLBP_Type.tp_alloc(&PyBobIpBaseLBP_Type, 0);
lbp->cxx = self->cxx->getXT();
return Py_BuildValue("O", lbp);
return Py_BuildValue("N", lbp);
BOB_CATCH_MEMBER("xt could not be read", 0)
}
......@@ -124,7 +124,7 @@ PyObject* PyBobIpBaseLBPTop_getYT(PyBobIpBaseLBPTopObject* self, void*){
BOB_TRY
PyBobIpBaseLBPObject* lbp = (PyBobIpBaseLBPObject*)PyBobIpBaseLBP_Type.tp_alloc(&PyBobIpBaseLBP_Type, 0);
lbp->cxx = self->cxx->getYT();
return Py_BuildValue("O", lbp);
return Py_BuildValue("N", lbp);
BOB_CATCH_MEMBER("yt could not be read", 0)
}
......@@ -261,4 +261,3 @@ bool init_BobIpBaseLBPTop(PyObject* module)
Py_INCREF(&PyBobIpBaseLBPTop_Type);
return PyModule_AddObject(module, "LBPTop", (PyObject*)&PyBobIpBaseLBPTop_Type) >= 0;
}
......@@ -350,6 +350,7 @@ static PyObject* PyBobIpBaseVLSIFT_extract(PyBobIpBaseVLSIFTObject* self, PyObje
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|O&", kwlist, &PyBlitzArray_Converter, &src, &PyBlitzArray_Converter, &keypoints)) return 0;
auto src_ = make_safe(src);
auto kp_ = make_xsafe(keypoints);
// perform checks on input and output image
if (src->ndim != 2 || src->type_num != NPY_UINT8){
......
......@@ -165,6 +165,7 @@ int PyBobIpBaseWiener_setPs(PyBobIpBaseWienerObject* self, PyObject* value, void
PyErr_Format(PyExc_RuntimeError, "%s %s expects a 2D array of floats", Py_TYPE(self)->tp_name, Ps.name());
return -1;
}
auto o_ = make_safe(o);
auto b = PyBlitzArrayCxx_AsBlitz<double,2>(o, "Ps");
if (!b) return -1;
self->cxx->setPs(*b);
......@@ -497,4 +498,3 @@ bool init_BobIpBaseWiener(PyObject* module)
Py_INCREF(&PyBobIpBaseWiener_Type);
return PyModule_AddObject(module, "Wiener", (PyObject*)&PyBobIpBaseWiener_Type) >= 0;
}
......@@ -54,6 +54,7 @@ Functions
bob.ip.base.crop
bob.ip.base.shift
bob.ip.base.extrapolate_mask
bob.ip.base.max_rect_in_mask
bob.ip.base.angle_to_horizontal
......@@ -76,4 +77,3 @@ Detailed Information
--------------------
.. automodule:: bob.ip.base
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment