summaryrefslogtreecommitdiff
path: root/docs/reference/src/util/nng_free.md
blob: e93e91e68c54c395d339e95f021affa8c3aabd6e (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
# nng_free

## NAME

nng_free --- free memory

## SYNOPSIS

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

void nng_free(void *ptr, size_t size);
```

## DESCRIPTION

The `nng_free()` function deallocates a memory region of size _size_,
that was previously allocated by [`nng_alloc()`][nng_alloc] or
[`nng_recv()`](../socket/nng_recv.md) with the `NNG_FLAG_ALLOC` flag.

> [!IMPORTANT]
> It is very important that _size_ match the allocation size
> used to allocate the memory.

> [!IMPORTANT]
> Do not attempt to use this function to deallocate memory
> obtained by a call to the system `malloc()` or `calloc()` functions,
> or the C++ `new` operator.
> Doing so may result in unpredictable
> behavior, including corruption of application memory.

## SEE ALSO

[nng_alloc][nng_alloc],
[nng_recv](../socket/nng_recv.md)

{{#include ../refs.md}}