FixNative Documentation
Back to summary
import "native/native";
Memory class
Pointer to memory region.
Inherits from Pointer.
Initialization
static function create(lo: Integer, hi: Integer, size: Integer, owned: Boolean): Memory
-
Creates a new memory region at given address and size. You can specify
if it should automatically deallocate it using
free
function
(when it's owned).
static function from_shared_array(shared_array[, offset: Integer, size: Integer]): Memory
-
Creates a memory view for the region used by the shared array with given
byte offset and size (or whole array). The reference to the shared array is
kept.
static function from_pointer(ptr: Pointer, offset: Integer, size: Integer): Memory
-
Creates a new memory region at address from given pointer using offset and size.
The memory region is unowned, you must keep reference to the original memory
to prevent crashes.
Allocation
static function alloc(size: Integer): Memory
-
Allocates a new memory region with given size. The memory is zeroed.
static function alloc_fast(size: Integer): Memory
-
Allocates a new memory region with given size. The memory is not zeroed.
function realloc(size: Integer): Memory
-
Rellocates the memory region with a new size. The old pointer must not
be used.
function free()
-
Frees the memory region.
Properties
function get_size(): Integer
-
Returns the size of the memory region.
function is_owned(): Boolean
-
Returns whether the memory region is owned (will be automatically deallocated).
Utility functions
static function for_string_utf8(s: String): Memory
-
Returns a new memory region with given UTF-8 zero-terminated string.