##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::free

From cppreference.com
< cpp‎ | memory‎ | c

Defined in header `<cstdlib>` |  |
void free( void* ptr ); |  |

Deallocates the space previously allocated by std::malloc(), std::calloc() or std::realloc(). If `ptr` is null-pointer, the function does nothing.

The behavior is undefined if `ptr` does not match a pointer returned earlier by std::malloc(), std::calloc() or std::realloc(). Also, the behavior is undefined if the memory area referred to by `ptr` has already been deallocated, that is, `free()` or std::realloc() has already been called with `ptr` as the argument and no calls to std::malloc(), std::calloc() or std::realloc() resulted in a pointer equal to `ptr` afterwards.

### [edit] Parameters

ptr | - | pointer to the memory to deallocate

### [edit] Return value

(none)

### [edit] Example

| This section is incomplete Reason: no example

### [edit] See also

C documentation for free

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/memory/c/free&oldid=64226"
Category:

- Todo no example