[zeromq-dev] zmq_recvmsg jni
Radu Braniste
rbraniste at gmail.com
Wed Oct 2 02:33:27 CEST 2013
Personally I'm using the direct buffer as a memory arena (I preallocate a
pool) and I avoid one allocation like:
*> zmq_msg_t msg;*>* zmq_msg_init (&msg);*>* zmq_recvmsg
((void *) socket, &msg, flags);*>* int size = zmq_msg_size
(&msg);*
*//might check for out of bounds and return false*
* memcpy(GetDirectBufferAccess(arena+used), zmq_msg_data (&msg), size);*
*used += size;*>* zmq_msg_close(&msg);*>* return used;*
the best would be of course to use this technique with a possible
"zmq_msg_init_data" as Peter suggested and completely avoid he extra
memcpy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20131001/4ed1c838/attachment.htm>
More information about the zeromq-dev
mailing list