Contents
KosMemAlloc()
This function is declared in the kos/alloc.h
file.
void *KosMemAlloc(rtl_size_t size);
This function allocates (reserves and commits) a memory area equal to the specific size
of bytes.
This function returns a pointer to the allocated area or RTL_NULL if memory could not be allocated.
Memory allocated by using the KosMemAlloc()
function has the following allocation flags: VMM_FLAG_READ | VMM_FLAG_WRITE, VMM_FLAG_RESERVE, VMM_FLAG_COMMIT, VMM_FLAG_LOCKED. To allocate memory with other allocation flags, use the KnVmAllocate()
function.
KosMemAllocEx()
This function is declared in the kos/alloc.h
file.
void *KosMemAllocEx(rtl_size_t size, rtl_size_t align, int zeroed);
This function is analogous to KosMemAlloc()
, but it also has additional parameters:
align
refers to the alignment of the memory area in bytes (power of two).zeroed
determines whether or not the memory area needs to be filled with zeros (1 means fill, 0 means do not fill).
KosMemFree()
This function is declared in the kos/alloc.h
file.
void KosMemFree(void *ptr);
This function frees a memory area that was allocated using the KosMemAlloc()
, KosMemZalloc()
or KosMemAllocEx()
function.
ptr
is the pointer to the freed memory area.
KosMemGetSize()
This function is declared in the kos/alloc.h
file.
rtl_size_t KosMemGetSize(void *ptr);
This function returns the size (in bytes) of the memory area allocated using the KosMemAlloc()
, KosMemZalloc()
or KosMemAllocEx()
function.
ptr
is the pointer to the memory area.
KosMemZalloc()
This function is declared in the kos/alloc.h
file.
void *KosMemZalloc(rtl_size_t size);
This function is analogous to KosMemAlloc()
, but it also fills the allocated memory area with zeros.