Skip to content

Commit

Permalink
Merge pull request #67 from K0n63n/master
Browse files Browse the repository at this point in the history
New fill constructor for message_t
  • Loading branch information
hintjens committed Dec 3, 2015
2 parents c86eb9e + fdd9d2d commit 7f7c834
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions zmq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 7f7c834

Please sign in to comment.