summaryrefslogtreecommitdiff
path: root/docs/ref/msg/nng_msg_alloc.adoc
blob: ae0e9184c202047dd92179dd59181529ac73e2d2 (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
## nng_msg_alloc

Allocate a message.

### Synopsis

```c
#include <nng/nng.h>

int nng_msg_alloc(nng_msg **msgp, size_t size);
```

### Description

The `nng_msg_alloc` function allocates a new message with body length _size_ and stores the result in __msgp__.
Messages allocated with this function contain a body and optionally a header.
They are used with receive and transmit functions.

### Return Values

This function returns 0 on success, and non-zero otherwise.

### Errors

[horizontal]
`NNG_ENOMEM`:: Insufficient free memory exists to allocate a message.

### See Also

xref:nng_msg_free.adoc[nng_msg_free],
xref:nng_msg_body.adoc[nng_msg_body],
xref:nng_msg_dup.adoc[nng_msg_dup],
xref:nng_msg_header.adoc[nng_msg_header],
xref:nng_msg_header_len.adoc[nng_msg_header_len],
xref:nng_msg_len.adoc[nng_msg_len],
xref:nng_msg_capacity.adoc[nng_msg_capacity],
xref:nng_msg_reserve.adoc[nng_msg_reserve],
xref:nng_msg_realloc.adoc[nng_msg_realloc],