Basic module

free

procedure2 overloadsSource

Gives memory back to the context allocator. It must come from alloc, New, realloc or another procedure that allocates with the context allocator, and must not be freed twice. Don't rely on freeing a null pointer.

free :: (memory: *void)

Parameters

memory: *void
Example↗
number := New(int);
free(number);
free :: (s: string)

Frees the memory a string points to. The string must have been allocated with the context allocator in effect now, for example by alloc_string, copy_string or sprint. Never free a string literal, a slice of another string or a string from temporary storage.

Parameters

s: string
Example↗
s := sprint("%-%", 1, 2);
assert(s == "1-2");
free(s);

See also