Free v0.1.0
Releases a block of memory back to the platform.
Package: Memory
Signature
func Free(ptr: *opaque);
Parameters
Remarks
Passing null is a no-op, so a caller needs no guard around the common
"allocate, maybe fail, clean up" path.
Anything else is undefined behavior and is not diagnosed: releasing the same
block twice, releasing a pointer that Realloc has already moved, or
passing a pointer this package did not produce. After the call the block is gone
and the pointer must not be read, written, or freed again.
Example
import Memory::{ Alloc, Free };
func Main() -> int {
let buffer = Alloc(256);
if buffer == null {
return 1;
}
Free(buffer);
Free(null); // harmless
return 0;
}