PDK API Guide for J721E
HeapP

Introduction

HeapP interface

Files

file  HeapP.h
 Heap management module for the RTOS Porting Interface.
 

Data Structures

struct  HeapP_Params
 Basic HeapP Parameters. More...
 
struct  HeapP_MemStats
 Structure used to pass information about the heap out of HeapP_getHeapStats(). More...
 

Functions

void HeapP_Params_init (HeapP_Params *params)
 Initialize params structure to default values. More...
 
HeapP_Handle HeapP_create (const HeapP_Params *params)
 Create a user defined heap. More...
 
HeapP_Status HeapP_delete (HeapP_Handle handle)
 Delete the user defined heap. More...
 
void * HeapP_alloc (HeapP_Handle handle, uint32_t allocSize)
 Alloc memory from user defined heap. More...
 
HeapP_Status HeapP_free (HeapP_Handle handle, void *ptr, uint32_t size)
 Free memory from user defined heap. More...
 
HeapP_Status HeapP_getHeapStats (HeapP_Handle handle, HeapP_MemStats *stats)
 Get detailed heap statistics. More...
 

Typedefs

typedef void * HeapP_Handle
 Opaque client reference to an instance of a HeapP. More...
 

Enumerations

enum  HeapP_Status { HeapP_OK = 0, HeapP_FAILURE = (-(int32_t)1) }
 Status codes for HeapP APIs. More...
 

Macros

#define HeapP_BYTE_ALIGNMENT   (256U)
 Minimum alignment for heap allocations, in units of bytes. More...
 

Macro Definition Documentation

◆ HeapP_BYTE_ALIGNMENT

#define HeapP_BYTE_ALIGNMENT   (256U)

Minimum alignment for heap allocations, in units of bytes.

Typedef Documentation

◆ HeapP_Handle

typedef void* HeapP_Handle

Opaque client reference to an instance of a HeapP.

A HeapP_Handle returned from the HeapP_create represents that instance and is used in the other instance based functions

Enumeration Type Documentation

◆ HeapP_Status

Status codes for HeapP APIs.

Enumerator
HeapP_OK 

API completed successfully

HeapP_FAILURE 

API failed

Function Documentation

◆ HeapP_Params_init()

void HeapP_Params_init ( HeapP_Params params)

Initialize params structure to default values.

Parameters
paramsPointer to the instance configuration parameters.

◆ HeapP_create()

HeapP_Handle HeapP_create ( const HeapP_Params params)

Create a user defined heap.

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

Parameters
paramsPointer to the instance configuration parameters.
Returns
A HeapP_Handle on success or a NULL on an error

◆ HeapP_delete()

HeapP_Status HeapP_delete ( HeapP_Handle  handle)

Delete the user defined heap.

Parameters
handle[in] Heap handle

◆ HeapP_alloc()

void* HeapP_alloc ( HeapP_Handle  handle,
uint32_t  allocSize 
)

Alloc memory from user defined heap.

Parameters
handle[in] Heap handle
allocSize[in] Size of memory to allocate

NOTE: Application should make sure that there is no buffer overflow. i.e., writing to memory beyond allocated size for this heap chunk would potentially cause unexpected failures. Specifically the heap implementation stores relevant software book-keeping parameters in the unallocated/free heap regions. Overflow of a previous allocated buffer could corrupt this and could cause issues with successive heap allocations. Similarly this could also corrupt the contents of successive allocated buffers as well.

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

◆ HeapP_free()

HeapP_Status HeapP_free ( HeapP_Handle  handle,
void *  ptr,
uint32_t  size 
)

Free memory from user defined heap.

Parameters
handle[in] Heap handle
ptr[in] Pointer to memory allocated using HeapP_alloc
size[in] Size of the block of memory to free

◆ HeapP_getHeapStats()

HeapP_Status HeapP_getHeapStats ( HeapP_Handle  handle,
HeapP_MemStats stats 
)

Get detailed heap statistics.

Parameters
handle[in] Heap handle
stats[out] Returned heap statistics