muteki
Loading...
Searching...
No Matches
heap.h File Reference

Heap memory management function hooks. More...

#include <muteki/common.h>

Go to the source code of this file.

Functions

void * osdep_heap_alloc (size_t size)
 Allocate and format mchx memchunk.
 
size_t osdep_heap_get_alloc_size (const void *ptr)
 Get usable size of an allocated mchx memchunk.
 
void osdep_heap_free (void *ptr)
 Free a mchx memchunk.
 
bool osdep_heap_trace_start (void)
 Start the heap tracer.
 
bool osdep_heap_trace_stop (void)
 Stop the heap tracer.
 

Detailed Description

Heap memory management function hooks.

The default allocator Besta RTOS provides aligns the memory it allocates to 4-bytes boundary, however the AAPCS requires memory to be aligned to 8-bytes boundary. This header file provides hooked version of allocator functions like malloc and free, which align the memory to 8-bytes boundary by inserting spaces conditionally, and also optionally traces the allocation done by the hooked functions.

Function Documentation

◆ osdep_heap_alloc()

void * osdep_heap_alloc ( size_t  size)
extern

Allocate and format mchx memchunk.

Parameters
sizeSize of the memory to allocate.
Returns
Pointer to allocated memory, or NULL if allocation fails.

◆ osdep_heap_free()

void osdep_heap_free ( void *  ptr)
extern

Free a mchx memchunk.

Parameters
ptrPointer to previously allocated memory.

Returns
None.

◆ osdep_heap_get_alloc_size()

size_t osdep_heap_get_alloc_size ( const void *  ptr)

Get usable size of an allocated mchx memchunk.

Parameters
ptrMemory allocated by osdep_heap_alloc().
Returns
Size of usable memory.

◆ osdep_heap_trace_start()

bool osdep_heap_trace_start ( void  )
extern

Start the heap tracer.

Parameters
None.

Return values
trueThe operation was completed successfully.
falseThe operation was completed successfully.

◆ osdep_heap_trace_stop()

bool osdep_heap_trace_stop ( void  )
extern

Stop the heap tracer.

Parameters
None.

Return values
trueThe operation was completed successfully.
falseThe operation was completed successfully.