nanomsg/nanomsg — pull request #241 by achille-roussel (2014-05-15 23:44:50+00:00)
Title: nn_reallocmsg

Hi guys,

Here's a patch for adding a nn_reallocmsg routine to nanomsg. The idea is to give the user an API for resizing a message without copying it.
The implementation relies on the system's realloc call (via nn_realloc) which may or may not cause the memory to be reused and then avoid a copy.
We could force the function to avoid calling realloc and simply modify the "size" attribute on the memory chunk when shrinking the message but I feel like that's outside the scope of nanomsg to start doing memory optimizations of this kind (especially since it comes with many edge cases), those decisions should be left to the memory management routines.
I added more test cases to tests/zerocopy.c to cover the new routine.

Feel free to request any changes if something looks wrong.

This patch is submitted under MIT license.