MicrOS
micros_heap.c File Reference
#include "micros_heap.h"

Functions

void * micros_heap_alloc (uint32_t size, uint32_t align)
 Allocates chunk of memory with the specified size and alignment. More...
 
void * micros_heap_realloc (void *ptr, uint32_t size)
 Reallocates chunk of memory with the specified size. More...
 
void micros_heap_dealloc (void *ptr)
 Deallocates chunk of memory. More...
 
uint32_t micros_heap_get_object_size (void *ptr)
 Retrieves size of the heap object. More...
 
bool micros_heap_verify_integrity ()
 Verifies heap integrity. More...
 
micros_heap_entrymicros_heap_get_process_heap ()
 Retrieves application heap. More...
 
void * micros_heap_kernel_alloc (uint32_t size, uint32_t align)
 
void * micros_heap_kernel_dealloc (void *address)
 

Function Documentation

◆ micros_heap_alloc()

void* micros_heap_alloc ( uint32_t  size,
uint32_t  align 
)

Allocates chunk of memory with the specified size and alignment.

Allocates chunk of memory with the specified size and alignment. Then returns pointer if success or 0 if there is not enough memory.

Parameters
sizeSize of the requested chunk of memory.
alignAlignment of the requested chunk of memory.
Returns
Pointer if success of 0 in there is not enough memory.

◆ micros_heap_dealloc()

void micros_heap_dealloc ( void *  ptr)

Deallocates chunk of memory.

Deallocates chunk of memory passed in the parameter.

Parameters
ptrPointer to the existing heap entry.

◆ micros_heap_get_object_size()

uint32_t micros_heap_get_object_size ( void *  ptr)

Retrieves size of the heap object.

Retrieves size of the heap object passed in the parameter.

Parameters
ptrPointer to the existing heap entry.
Returns
Size of the heap object.

◆ micros_heap_get_process_heap()

micros_heap_entry* micros_heap_get_process_heap ( )

Retrieves application heap.

Retrieves application heap by returning first first entry.

Returns
Pointer to the first entry of the application heap.

◆ micros_heap_kernel_alloc()

void* micros_heap_kernel_alloc ( uint32_t  size,
uint32_t  align 
)

◆ micros_heap_kernel_dealloc()

void* micros_heap_kernel_dealloc ( void *  address)

◆ micros_heap_realloc()

void* micros_heap_realloc ( void *  ptr,
uint32_t  size 
)

Reallocates chunk of memory with the specified size.

Reallocates chunk of memory with the specified size. Then returns pointer if success or 0 if there is not enough memory.

Parameters
ptrPointer to the existing heap entry.
sizeSize of the requested chunk of memory.
Returns
Pointer if success of 0 in there is not enough memory.

◆ micros_heap_verify_integrity()

bool micros_heap_verify_integrity ( )

Verifies heap integrity.

Verifies heap integrity (objects aren't overlapping and sizes are correctly set) and returns boolean with result.

Returns
True if heap is in the valid state, otherwise false.