AM261x MCU+ SDK: APIs for Heap management

| AM261x MCU+ SDK 26.00.00 |

Data Structures | Functions | Macros
APIs for Heap management
APIs for Driver Porting Layer

## Introduction

For more details and example usage, see Heap

## Data Structures
struct | HeapP_MemStats
| Structure used to pass information about the heap out of HeapP_getHeapStats(). More...
struct | HeapBlockLink_t
| The linked list structure is used to link free blocks in order of their memory address. More...
struct | StaticHeap_t
| Static heap instance structure. More...
struct | HeapP_Object
| Opaque heap object used with the heap APIs. More...

## Functions
int32_t | HeapP_construct (HeapP_Object *heapObj, void *heapAddr, size_t heapSize)
| Create a user defined heap. More...
void | HeapP_destruct (HeapP_Object *heapObj)
| Delete the user defined heap. More...
void * | HeapP_alloc (HeapP_Object *heapObj, size_t allocSize)
| Alloc memory from user defined heap. More...
int32_t | HeapP_free (HeapP_Object *heapObj, void *ptr)
| Free memory from user defined heap. More...
size_t | HeapP_getFreeHeapSize (HeapP_Object *heapObj)
| Get free heap size, in bytes. More...
size_t | HeapP_getMinimumEverFreeHeapSize (HeapP_Object *heapObj)
| Get lowest ever free heap size, in bytes. More...
int32_t | HeapP_getHeapStats (HeapP_Object *heapObj, HeapP_MemStats *pHeapStats)
| Get detailed heap statistics. More...

## Macros
#define | HeapP_BYTE_ALIGNMENT (64u)
| Minimum alignment for heap allocations, in units of bytes. More...

## Macro Definition Documentation

## ◆ HeapP_BYTE_ALIGNMENT

#define HeapP_BYTE_ALIGNMENT (64u)

Minimum alignment for heap allocations, in units of bytes.

## Function Documentation

## ◆ HeapP_construct()

int32_t HeapP_construct | ( | HeapP_Object * | heapObj,
|  | void * | heapAddr,
|  | size_t | heapSize
| ) |  |

Create a user defined heap.

The actual heap start address and size will be adjusted to satisfy HeapP_BYTE_ALIGNMENT.

Parameters

  heapObj | [out] Initalized heap object to be used for subsequent API calls
  heapAddr | [in] Base address of memory to be used as heap
  heapSize | [in] Size of memory block that is to be used as heap

Returns
  SystemP_SUCCESS on success, SystemP_FAILURE on error

## ◆ HeapP_destruct()

void HeapP_destruct | ( | HeapP_Object * | heapObj | ) |

Delete the user defined heap.

Parameters

  heapObj | [in] Heap object

## ◆ HeapP_alloc()

void* HeapP_alloc | ( | HeapP_Object * | heapObj,
|  | size_t | allocSize
| ) |  |

Alloc memory from user defined heap.

Parameters

  heapObj | [in] Heap object
  allocSize | [in] Size of memory to allocate

Returns
  pointer to allcoated memory
  NULL memory could not be allocated since a free block of required size could not be found

## ◆ HeapP_free()

int32_t HeapP_free | ( | HeapP_Object * | heapObj,
|  | void * | ptr
| ) |  |

Free memory from user defined heap.

Parameters

  heapObj | [in] Heap object
  ptr | [in] Pointer to memory allocated using HeapP_alloc

Returns
  SystemP_SUCCESS on success, SystemP_FAILURE on error

## ◆ HeapP_getFreeHeapSize()

size_t HeapP_getFreeHeapSize | ( | HeapP_Object * | heapObj | ) |

Get free heap size, in bytes.

Parameters

  heapObj | [in] Heap object

Returns
  Free memory size in this heap, in bytes

## ◆ HeapP_getMinimumEverFreeHeapSize()

size_t HeapP_getMinimumEverFreeHeapSize | ( | HeapP_Object * | heapObj | ) |

Get lowest ever free heap size, in bytes.

Parameters

  heapObj | [in] Heap object

Returns
  Lowest ever free heap size, in bytes

## ◆ HeapP_getHeapStats()

int32_t HeapP_getHeapStats | ( | HeapP_Object * | heapObj,
|  | HeapP_MemStats * | pHeapStats
| ) |  |

Get detailed heap statistics.

Parameters

  heapObj | [in] Heap object
  pHeapStats | [out] Returned heap statistics

Returns
  SystemP_SUCCESS on success, SystemP_FAILURE on error