You seem to have mixed up your struct definition and the code that uses it - the two don't use the same struct member names.
Apart from that, as CPallini suggested, the easiest way is to define a destructor to your struct. And to make sure that all pointers within the struct are initialized correctly, you should also add a destructor (if you don't, you won't know for sure whether a pointer that is not NULL actually points to allocated memory, or just hasn't been initialized).
Try this:
struct PARAMS_STRUCT {
PARAMS_STRUCT()
: mean_x(NULL), std_x(NULL),
alfaXlabels(NULL),
train_mat(NULL),
pDst(NULL),
dot_b(NULL)
{
}
~PARAMS_STRUCT()
{
delete mean_x;
delete std_x;
delete alfaXlabels;
delete train_mat;
delete pDst;
delete dot_b;
}
float* mean_x;
float* std_x;
float* alfaXlabels;
float* train_mat;
float* pDst;
float* dot_b;
};
PARAMS_STRUCT* m_params = new PARAMS_STRUCT[m_NumOfClasses*(m_NumOfClasses-1)/2];
delete [] m_params;
Note that the constructor and destructor will be called automatically when you invoke
new
and
delete
, so you don't have to take care of cleaning up everywhere you release your memory.