Merge pull request #67 from K0n63n/master

New fill constructor for message_t
This commit is contained in:
Pieter Hintjens 2015-12-03 09:15:21 +01:00
commit 7f7c83411d

19
zmq.hpp
View File

@ -227,6 +227,14 @@ namespace zmq
}
}
inline message_t (const void *data_, size_t size_)
{
int rc = zmq_msg_init_size (&msg, size_);
if (rc != 0)
throw error_t ();
memcpy(data(), data_, size_);
}
inline message_t (void *data_, size_t size_, free_fn *ffn_,
void *hint_ = NULL)
{
@ -276,6 +284,17 @@ namespace zmq
throw error_t ();
}
inline void rebuild (const void *data_, size_t size_)
{
int rc = zmq_msg_close (&msg);
if (rc != 0)
throw error_t ();
rc = zmq_msg_init_size (&msg, size_);
if (rc != 0)
throw error_t ();
memcpy(data(), data_, size_);
}
inline void rebuild (void *data_, size_t size_, free_fn *ffn_,
void *hint_ = NULL)
{