Memory

#import Builtin.Memory;

A builtin module adding useful memory management tools

Functions


malloc(int)

malloc :: *int(b : int64)

Allocates a block of memory

Arguments

b
int64
int64 The number of bytes to allocate

Returns:

A pointer to the allocated memory block

free(pointer)

free :: (p : *int)

Frees a block of memory previously allocated by malloc

Arguments

p
*int
Pointer to the memory block to free

strcmp(*char, *char)

strcmp :: int(a : *char, b : *char)

Compares two null-terminated character arrays lexicographically

Arguments

a
*char
First null-terminated string
b
*char
Second null-terminated string

Returns:

0 if equal, negative if a < b, positive if a > b

strstr(*char, *char)

strstr :: *char(haystack : *char, needle : *char)

Finds the first occurrence of needle in haystack

Returns:

Pointer to the first match, or null if not found