free
<alloc>
function
[defunc [free [void* ptr]] -> void]
fn free(ptr: void*): void {}
fn free(ptr: void*): void {}
The free
function releases a block of memory that was previously allocated by malloc
, calloc
, or realloc
. The behavior is undefined if the memory block has already been released or if the pointer is invalid.
Examples
[include "std"]
[define [void* ptr] [std::malloc 4]]
[std::free ptr]
#include "std"
void* ptr = std::malloc(4);
std::free(ptr);
import malloc, free from 'std';
let ptr = malloc(4);
free(ptr);
See Also
alloc/malloc | Allocate a block of memory. |
alloc/realloc | Re-allocate a block of memory. |
alloc/premalloc | Pre-allocates a block of memory. |