Fixed a memory leak in mxarray
This commit is contained in:
parent
eb3a83209c
commit
1dd017e9d0
@ -113,7 +113,7 @@ template<typename _Tp = DefaultTraits> class Traits {
|
|||||||
public:
|
public:
|
||||||
static const mxClassID ScalarType = mxUNKNOWN_CLASS;
|
static const mxClassID ScalarType = mxUNKNOWN_CLASS;
|
||||||
static const mxComplexity Complex = mxCOMPLEX;
|
static const mxComplexity Complex = mxCOMPLEX;
|
||||||
static const mxComplexity Real = mxCOMPLEX;
|
static const mxComplexity Real = mxREAL;
|
||||||
static std::string ToString() { return "Unknown/Unsupported"; }
|
static std::string ToString() { return "Unknown/Unsupported"; }
|
||||||
};
|
};
|
||||||
// bool
|
// bool
|
||||||
@ -248,6 +248,16 @@ public:
|
|||||||
*/
|
*/
|
||||||
MxArray() : ptr_(mxCreateDoubleMatrix(0, 0, matlab::Traits<>::Real)), owns_(true) {}
|
MxArray() : ptr_(mxCreateDoubleMatrix(0, 0, matlab::Traits<>::Real)), owns_(true) {}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief destructor
|
||||||
|
*
|
||||||
|
* The destructor deallocates any data allocated by mxCreate* methods only
|
||||||
|
* if the object is owned
|
||||||
|
*/
|
||||||
|
virtual ~MxArray() {
|
||||||
|
dealloc();
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief inheriting constructor
|
* @brief inheriting constructor
|
||||||
*
|
*
|
||||||
@ -267,7 +277,8 @@ public:
|
|||||||
*
|
*
|
||||||
* This constructor explicitly creates an MxArray of the given size and type.
|
* This constructor explicitly creates an MxArray of the given size and type.
|
||||||
*/
|
*/
|
||||||
MxArray(size_t m, size_t n, size_t k, mxClassID id, mxComplexity com = matlab::Traits<>::Real) : owns_(true) {
|
MxArray(size_t m, size_t n, size_t k, mxClassID id, mxComplexity com = matlab::Traits<>::Real)
|
||||||
|
: ptr_(NULL), owns_(true) {
|
||||||
mwSize dims[] = { static_cast<mwSize>(m), static_cast<mwSize>(n), static_cast<mwSize>(k) };
|
mwSize dims[] = { static_cast<mwSize>(m), static_cast<mwSize>(n), static_cast<mwSize>(k) };
|
||||||
ptr_ = mxCreateNumericArray(3, dims, id, com);
|
ptr_ = mxCreateNumericArray(3, dims, id, com);
|
||||||
}
|
}
|
||||||
@ -318,16 +329,6 @@ public:
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief destructor
|
|
||||||
*
|
|
||||||
* The destructor deallocates any data allocated by mxCreate* methods only
|
|
||||||
* if the object is owned
|
|
||||||
*/
|
|
||||||
virtual ~MxArray() {
|
|
||||||
dealloc();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief copy constructor
|
* @brief copy constructor
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user