mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-18 03:29:49 +02:00
Problem: deallocate calls release after de-allocation
Solution: reduce to newly extracted function clear, which does not use the freed pointer
This commit is contained in:
@@ -108,17 +108,21 @@ void zmq::shared_message_memory_allocator::deallocate ()
|
|||||||
if (buf && !c->sub (1)) {
|
if (buf && !c->sub (1)) {
|
||||||
std::free (buf);
|
std::free (buf);
|
||||||
}
|
}
|
||||||
release ();
|
clear ();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char *zmq::shared_message_memory_allocator::release ()
|
unsigned char *zmq::shared_message_memory_allocator::release ()
|
||||||
{
|
{
|
||||||
unsigned char *b = buf;
|
unsigned char *b = buf;
|
||||||
|
clear ();
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
void zmq::shared_message_memory_allocator::clear ()
|
||||||
|
{
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
bufsize = 0;
|
bufsize = 0;
|
||||||
msg_content = NULL;
|
msg_content = NULL;
|
||||||
|
|
||||||
return b;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void zmq::shared_message_memory_allocator::inc_ref ()
|
void zmq::shared_message_memory_allocator::inc_ref ()
|
||||||
|
@@ -120,6 +120,8 @@ class shared_message_memory_allocator
|
|||||||
void advance_content () { msg_content++; }
|
void advance_content () { msg_content++; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void clear ();
|
||||||
|
|
||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
std::size_t bufsize;
|
std::size_t bufsize;
|
||||||
const std::size_t max_size;
|
const std::size_t max_size;
|
||||||
|
Reference in New Issue
Block a user