IBNOS
Functions
Heap

Functions

void * heapAlloc (uint32_t length)
 Allocates a block of kernel memory. More...
 
void heapFree (void *addr)
 Deallocates a block of kernel memory. More...
 
uint32_t heapSize (void *addr)
 Determines the size of a specific kernel memory block. More...
 
void * heapReAlloc (void *addr, uint32_t length)
 Resizes a block of kernel memory. More...
 
void heapVerify ()
 Runs some internal checks to ensure that the heap is still valid. More...
 

Detailed Description

Function Documentation

◆ heapAlloc()

void* heapAlloc ( uint32_t  length)

Allocates a block of kernel memory.

Allocates a block of kernel memory of the requested size. The algorithm will always return a pointer aligned to a 16-byte boundary, or NULL if the request cannot be fulfilled. The new memory block will not be initialized.

Parameters
lengthNumber of bytes to allocate
Returns
Pointer to the allocated memory block or NULL if the request cannot be fulfilled

Definition at line 363 of file allocator.c.

◆ heapFree()

void heapFree ( void *  addr)

Deallocates a block of kernel memory.

Verifies that the provided memory pointer is valid, and afterwards releases the full block. If something goes wrong an assertion is thrown. This typically means that the application has corrupted the block header.

Parameters
addrPointer to a memory block allocated with heapAlloc()

Definition at line 385 of file allocator.c.

◆ heapReAlloc()

void* heapReAlloc ( void *  addr,
uint32_t  length 
)

Resizes a block of kernel memory.

Provides a fast method to change the size of a memory block. If the return value is NULL then it was impossible to fulfill the request (for example not enough memory left). Otherwise this function returns a pointer to the new location of the memory block, which can be, but is not necessarily equal to the previous location. The new bytes of memory are not initialized before this function returns.

Parameters
addrPointer to a memory block
lengthNew requested length
Returns
Pointer to a new block of kernel memory

Definition at line 439 of file allocator.c.

◆ heapSize()

uint32_t heapSize ( void *  addr)

Determines the size of a specific kernel memory block.

Returns the number of bytes of a specific kernel memory block. The result of this function can be greater than the requested size specified when calling heapAlloc() due to align issues.

Parameters
addrPointer to a memory block allocated with heapAlloc()
Returns
Size of the memory block in bytes

Definition at line 411 of file allocator.c.

◆ heapVerify()

void heapVerify ( )

Runs some internal checks to ensure that the heap is still valid.

Definition at line 485 of file allocator.c.