On Sun, Apr 3, 2011 at 11:31 AM, Martin Sustrik <[email protected]> wrote:

> As for merging zmq_msg_init with zmq_msg_init_size the only downside is that
> it makes receiving a message look a bit strange:
>
> zmq_msg_t msg;
> size_t size = 0;
> zmq_msg_init_size (&msg, size); // instead of zmq_msg_init (&msg);
> zmq_recvmsg (s, &msg, 0);

I'd use this syntax:

zmq_msg_t msg;
zmq_msg_init (&msg, 0);  // instead of zmq_msg_init (&msg);
zmq_recvmsg (s, &msg, 0);

It does make receiving a message slightly weird, but it gives a single
'normal' init method, which is worth a lot IMO.

It would be nicer IMO if zmq_recvmsg automatically initialized the
message before reading. It might be necessary to write something like:

zmq_msg_t msg = {0};
zmq_recvmsg (s, &msg, 0);

Anything that reduces the number of calls required, and the potential
for confusion, in the simple/common cases will be a win IMO.

-Pieter
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to