mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-13 01:31:20 +00:00
Merge pull request #4145 from gummif/gfa/malloc-vec
Problem: C style malloc and free
This commit is contained in:
commit
c515671bc8
@ -46,7 +46,7 @@ template <typename T, size_t S> class fast_vector_t
|
|||||||
explicit fast_vector_t (const size_t nitems_)
|
explicit fast_vector_t (const size_t nitems_)
|
||||||
{
|
{
|
||||||
if (nitems_ > S) {
|
if (nitems_ > S) {
|
||||||
_buf = static_cast<T *> (malloc (nitems_ * sizeof (T)));
|
_buf = new (std::nothrow) T[nitems_];
|
||||||
// TODO since this function is called by a client, we could return errno == ENOMEM here
|
// TODO since this function is called by a client, we could return errno == ENOMEM here
|
||||||
alloc_assert (_buf);
|
alloc_assert (_buf);
|
||||||
} else {
|
} else {
|
||||||
@ -59,7 +59,7 @@ template <typename T, size_t S> class fast_vector_t
|
|||||||
~fast_vector_t ()
|
~fast_vector_t ()
|
||||||
{
|
{
|
||||||
if (_buf != _static_buf)
|
if (_buf != _static_buf)
|
||||||
free (_buf);
|
delete[] _buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user