[zeromq-dev] zsock_brecv documentation

Luca Boccassi luca.boccassi at gmail.com
Sat Jul 22 14:15:47 CEST 2017


On Sat, 2017-07-22 at 09:54 +0000, Juergen Gnoss wrote:
> Problem: zsock_brecv documentation
> 
> There was an issue on Dec 2015 #1223
> 
> https://github.com/zeromq/czmq/issues/1223
> 
> and it has been fixed
> 
> actual documentation says
> 
> // Note that zsock_brecv creates the returned objects, and the caller
> must
> 
> // destroy them when finished with them.
> 
> OK that's clear if it is clear what an object is.
> 
> //      c       zchunk_t *              type = "chunk"
> //      f       zframe_t *              type = "frame"
> //      u       zuuid_t *               type = "uuid"
> //      m       zmsg_t *                type = "msg"
> 
> could be easy identified as objects
> 
> but what's about
> 
> //      s       char *, 0-255 chars     type = "string"
> //      S       char *, 0-2^32-1 chars  type = "longstr"
> 
> a longstr I have to free, a string not
> 
> if I try to destroy a string valgrind complains with
> 
> Invalid free() / delete / delete[] / realloc()
> 
> ‘’’c
> 
> int res = 0;
> char *data;
> char *cmd;
> 
> 
>     res = zsock_brecv(self->workerClient, "sS", &cmd, &data);
>     if (res != 0) {
>         fprintf(stderr, "error receive msg from worker server\n%s\n",
> zmq_strerror (errno));
>     } else {
>         do something with cmd and data
>     }
>     if (cmd != NULL) {
>         free(cmd);
>     }
>     if (data != NULL) {
>         free(data);
>     }
> 
> 
> ‘’’
> 
> Am I the only one running into that trap?
> 
> Ju

Yes it was a bit wrong and confusing. I've now updated the
documentation: https://github.com/zeromq/czmq/pull/1712

-- 
Kind regards,
Luca Boccassi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20170722/a4ce3973/attachment.sig>


More information about the zeromq-dev mailing list