[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #61472] AddressSanitizer crash in MEX tests
From: |
anonymous |
Subject: |
[Octave-bug-tracker] [bug #61472] AddressSanitizer crash in MEX tests |
Date: |
Tue, 23 Nov 2021 01:42:44 -0500 (EST) |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; rv:94.0) Gecko/20100101 Firefox/94.0 |
Follow-up Comment #3, bug #61472 (project octave):
Hello there!
Regarding comment #1:
A custom deleter can be provided to the constructor of `Array`. The Array also
needs a member of type deleter:
using deleter_t = void (*)(void *);
template<typename T>
class Array
{
public:
Array (const dim_vector& dv)
: m_data (new T[dv.safe_numel ()])
, m_dv (dv)
, m_deleter ([](void *p){::operatr delete[] (p);})
{}
Array (T *buffer, const dim_vector& dv, deleter_t del)
: m_data (buffer)
, m_dv (dv)
, m_deleter (del)
{}
~Array()
{
deleter (m_data);
}
private:
T *m_data;
dim_vector m_dv;
deleter_t m_deleter;
};
It can be used like this:
double * buf = (double *) std::malloc (5 * sizeof (double));
Array<doudblr> arr (buf, dim_vector (1, 5), &std::free);
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?61472>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/