## nng_msg_dup

Duplicate a message.

### Synopsis

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

int nng_msg_dup(nng_msg **dup, nng_msg_t *orig);
```

### Description

The `nng_msg_dup` makes a duplicate of the original message _orig_, and saves the result in the location pointed by _dup_.
The actual message body and header content is copied, but the duplicate may contain a different amount of unused space than the original message.

### Return Values

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

### Errors

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

### See Also

xref:nng_msg_alloc.adoc[nng_msg_alloc],
xref:nng_msg_free.adoc[nng_msg_free]
