Free
Releases a heap block previously returned by Alloc or Realloc.
Module: Std::Memory
Signature
rux
func Free(ptr: *opaque);Parameters
| Name | Type | Description |
|---|---|---|
ptr | *opaque | Pointer from Alloc/Realloc, or null. |
Description
Free returns a block of memory to the heap. Passing null is safe and does nothing, so you don't need to guard the call.
WARNING
Each allocation must be freed exactly once. Using a pointer after it has been freed, or freeing the same pointer twice, is undefined behavior.
Example
rux
import Std::Memory::*;
let buffer = Alloc(256);
if buffer == null {
return 1;
}
// ... use the buffer ...
Free(buffer);