## nn_allocmsg Allocate message (compatible API). ### Synopsis ```c #include void *nn_allocmsg(size_t size, int type); ``` ### Description The `nn_allocmsg` allocates a message structure of size _size_, and is primarily used to support zero-copy send operations, making use of the `NNG_MSG` special size indicator. The value returned is a pointer to the start of the message payload buffer. The value of _size_ must be positive, and small enough to hold reasonable message data plus book-keeping information. The value of _type_ *must* be zero. The returned message must be disposed of by either xref:nn_freemsg.adoc[`nn_freemsg`] or xref:nn_send.adoc[`nn_send`] when the caller is finished with it. ### Return Values This function returns a pointer to message buffer space, or `NULL` on failure. ### Errors [horizontal] `ENOMEM`:: Insufficient memory is available. `EINVAL`:: An invalid _size_ or _type_ was specified. `ETERM`:: The library is shutting down. ### See Also xref:nn_errno.adoc[nn_errno], xref:nn_freemsg.adoc[nn_freemsg], xref:nn_reallocmsg.adoc[nn_reallocmsg], xref:nn_send.adoc[nn_send]