blob: 273f17e681006383ab8deabf64efafc09b17c5d5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
## nn_allocmsg
Allocate message (compatible API).
### Synopsis
```c
#include <nanomsg/nn.h>
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]
|