[zeromq-dev] Java to C++: junk appended to message?

Wolfgang Richter wolf at cs.cmu.edu
Mon Aug 30 21:22:13 CEST 2010

On Mon, 2010-08-30 at 21:06 +0200, Pieter Hintjens wrote:
> On Mon, Aug 30, 2010 at 9:00 PM, Jon Dyte <jon at totient.co.uk> wrote:
> > i don't think it should add bytes either.
> Well, it would be invisible and the only side-effect be 1 extra byte
> of allocated memory, and the ability to pass message data to printf
> safely if it's character data...
> > and there is an option to allocate the buffer yr self and supply a free
> > function. which would break with this?
> Nope, this idea is for received messages, not sent messages.
> I've been playing with this in ZFL blobs and it's really quite nice.
> It lets you treat strings as character sequences without terminating
> nulls.

I also think it is nice, but I think that the user code should handle
this and the library should not have special support for
string/character data.

I think most functions will let you also deal with data by specifying a

"With a variable precision, you can print a substring, or print a
non-NUL-terminated string, if you know its length. printf("%.*s\n",
sublen, str) prints the first sublen characters of str."

printf and its family of functions all support this, no need for a
NUL-terminator if you don't have one.

Also, say you want to do strcmp(), just use strncmp() with max length

Is there a compelling use-case to add this into 0MQ?

More information about the zeromq-dev mailing list