Heap

Heap service provides dynamic memory allocation and deallocation for the kernel and user applications. It also provides heap usage statistics for debugging and memory analysis.

Initialization

void heap_init()

Heap memory initialization.

Note

This function will be called by the kernel

Parameters:

none – [in]

Returns:

none

Memory Management

void *heap_malloc(size_t size)

Heap memory allocation.

Parameters:

size – [in] size of memory to allocate

Returns:

  • pointer to allocated memory (allocated successfully)

  • NULL if memory allocation fails

void heap_free(void *addr)

Heap memory free.

Parameters:

addr – [in] pointer to memory to free (MUST-BE not NULL)

Returns:

none

Heap Information

void heap_info()

Heap usage information.

This function prints the current status of the heap, including total size, used size, free size, and fragmentation level.

Parameters:

none – [in]

Returns:

none