Commit 6ffaff25 authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

Solved memory leaks found in the test bob.lear.em.test.test_gmm

parent 0583a450
......@@ -31,6 +31,7 @@ bob::learn::em::GMMMachine::GMMMachine(const GMMMachine& other)
copy(other);
}
bob::learn::em::GMMMachine& bob::learn::em::GMMMachine::operator=(const bob::learn::em::GMMMachine &other) {
// protect against invalid self-assignment
if (this != &other)
......@@ -91,7 +92,9 @@ void bob::learn::em::GMMMachine::copy(const GMMMachine& other) {
initCache();
}
bob::learn::em::GMMMachine::~GMMMachine() { }
bob::learn::em::GMMMachine::~GMMMachine() {
}
/////////////////////
......
......@@ -720,16 +720,13 @@ static PyObject* PyBobLearnEMGMMMachine_get_gaussian(PyBobLearnEMGMMMachineObjec
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i", kwlist, &i)) return 0;
boost::shared_ptr<bob::learn::em::Gaussian> gaussian = self->cxx->getGaussian(i);
//Allocating the correspondent python object
PyBobLearnEMGaussianObject* retval =
(PyBobLearnEMGaussianObject*)PyBobLearnEMGaussian_Type.tp_alloc(&PyBobLearnEMGaussian_Type, 0);
retval->cxx = gaussian;
//return reinterpret_cast<PyObject*>(retval);
return Py_BuildValue("O",retval);
retval->cxx = self->cxx->getGaussian(i);
return Py_BuildValue("N",retval);
BOB_CATCH_MEMBER("cannot compute the likelihood", 0)
}
......
......@@ -84,13 +84,23 @@ static int PyBobLearnEMGMMStats_init_hdf5(PyBobLearnEMGMMStatsObject* self, PyOb
char** kwlist = GMMStats_doc.kwlist(2);
/*
PyBobIoHDF5FileObject* config = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&", kwlist, &PyBobIoHDF5File_Converter, &config)){
GMMStats_doc.print_usage();
return -1;
}
*/
self->cxx.reset(new bob::learn::em::GMMStats(*(config->f)));
PyObject* config = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!", kwlist, &PyBobIoHDF5File_Type, &config)){
GMMStats_doc.print_usage();
return -1;
}
auto h5f = reinterpret_cast<PyBobIoHDF5FileObject*>(config);
self->cxx.reset(new bob::learn::em::GMMStats(*(h5f->f)));
return 0;
}
......
Supports Markdown
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