mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-12 17:12:46 +00:00
Problem: fast vector resize bug
Solution: init correct vector size and copy previous data into it
This commit is contained in:
parent
80fef55955
commit
056f37f352
@ -76,12 +76,13 @@ template <typename T, size_t S> class resizable_fast_vector_t
|
||||
|
||||
void resize (const size_t nitems_)
|
||||
{
|
||||
if (_dynamic_buf)
|
||||
if (_dynamic_buf) {
|
||||
_dynamic_buf->resize (nitems_);
|
||||
if (nitems_ > S) {
|
||||
_dynamic_buf = new (std::nothrow) std::vector<T>;
|
||||
} else if (nitems_ > S) {
|
||||
_dynamic_buf = new (std::nothrow) std::vector<T> (nitems_);
|
||||
// TODO since this function is called by a client, we could return errno == ENOMEM here
|
||||
alloc_assert (_dynamic_buf);
|
||||
memcpy(&(*_dynamic_buf)[0], _static_buf, sizeof _static_buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user