Maestro Audio Framework  v 1.0
NXP Semiconductors
osa_memory.h File Reference

Contains memory allocation function prototypes for Maestro libosa. More...

#include "lib_common.h"

Macros

#define MAX_IO_COMPONENTS   0
 
#define MEM_TYPE_COMPONENT_SHIFT   12
 
#define OSA_MEMTYPE_BASE
 
#define OSA_MEMTYPE_SEGMENT_SHIFT   10
 
#define OSA_FWMEMTYPE_BASE   (OSA_MEMTYPE_BASE)
 The base value of allocating memory type definition for framework.
 
#define OSA_METADATAMGR_MEMTYPE_BASE
 The base value of allocating memory type definition for metadata mgr. More...
 
#define OSA_DEVICEMGR_MEMTYPE_BASE
 The base value of allocating memory type definition for Device Manager. More...
 
#define OSA_INPUTMGR_MEMTYPE_BASE
 The base value of allocating memory type definition for af. More...
 
#define OSA_PSMMEMTYPE_BASE
 The base value of allocating memory type definition for application. More...
 
#define OSA_OSAMEMTYPE_BASE
 The base value of allocating memory type definition for OSA. More...
 
#define OSA_AF_MEMTYPE_BASE
 The base value of allocating memory type definition for af. More...
 
#define OSA_APPS_MEMTYPE_BASE
 The base value of allocating memory type definition for test-apps. More...
 
#define OSA_PARSERS_MEMTYPE_BASE
 The base value of allocating memory type definition for parsers. More...
 

Functions

void * osa_malloc (size_t size)
 Allocate system memory. More...
 
void * osa_calloc (size_t nmemb, size_t size)
 Allocate system memory and zero it. More...
 
void * osa_realloc (void *ptr, size_t size)
 Change the size of a memory block. More...
 
void osa_free (void *ptr)
 Free system memory. More...
 
void * osa_memcpy (void *dest, const void *src, size_t n)
 Copy memory area. More...
 
void * osa_memset (void *src, char c, size_t n)
 Fill memory with a constant byte. More...
 
void * osa_memmove (void *dest, const void *src, size_t n)
 Copy memory area. More...
 
void osa_set_memtype (void *ptr, uint32_t type)
 set the owner of the memory block More...
 

Macro Definition Documentation

◆ OSA_MEMTYPE_BASE

#define OSA_MEMTYPE_BASE
Value:
((MAX_IO_COMPONENTS + 1) << \
(MEM_TYPE_COMPONENT_SHIFT))

◆ OSA_METADATAMGR_MEMTYPE_BASE

#define OSA_METADATAMGR_MEMTYPE_BASE
Value:
(OSA_MEMTYPE_BASE + \
(1 << OSA_MEMTYPE_SEGMENT_SHIFT))

◆ OSA_DEVICEMGR_MEMTYPE_BASE

#define OSA_DEVICEMGR_MEMTYPE_BASE
Value:
(OSA_MEMTYPE_BASE + \
(2 << OSA_MEMTYPE_SEGMENT_SHIFT))

◆ OSA_INPUTMGR_MEMTYPE_BASE

#define OSA_INPUTMGR_MEMTYPE_BASE
Value:
(OSA_MEMTYPE_BASE + \
(3 << OSA_MEMTYPE_SEGMENT_SHIFT))

◆ OSA_PSMMEMTYPE_BASE

#define OSA_PSMMEMTYPE_BASE
Value:
(OSA_MEMTYPE_BASE + \
(4 << OSA_MEMTYPE_SEGMENT_SHIFT))

◆ OSA_OSAMEMTYPE_BASE

#define OSA_OSAMEMTYPE_BASE
Value:
(OSA_MEMTYPE_BASE + \
(5 << OSA_MEMTYPE_SEGMENT_SHIFT))

◆ OSA_AF_MEMTYPE_BASE

#define OSA_AF_MEMTYPE_BASE
Value:
(OSA_MEMTYPE_BASE + \
(6 << OSA_MEMTYPE_SEGMENT_SHIFT))

◆ OSA_APPS_MEMTYPE_BASE

#define OSA_APPS_MEMTYPE_BASE
Value:
(OSA_MEMTYPE_BASE + \
(7 << OSA_MEMTYPE_SEGMENT_SHIFT))

◆ OSA_PARSERS_MEMTYPE_BASE

#define OSA_PARSERS_MEMTYPE_BASE
Value:
(OSA_MEMTYPE_BASE + \
(8 << OSA_MEMTYPE_SEGMENT_SHIFT))

Function Documentation

◆ osa_malloc()

void* osa_malloc ( size_t  size)
Parameters
sizeThe number of bytes to allocate
Returns
A pointer to the allocated memory block or NULL on failure

◆ osa_calloc()

void* osa_calloc ( size_t  nmemb,
size_t  size 
)
Parameters
nmembThe number of elements to allocate
sizeThe size in bytes of each element
Returns
A pointer to the allocated memory block or NULL on failure

◆ osa_realloc()

void* osa_realloc ( void *  ptr,
size_t  size 
)
Parameters
ptrThe existing memory block
sizeThe size of the new memory block
Returns
A pointer to the allocated memory block or NULL on failure

◆ osa_free()

void osa_free ( void *  ptr)
Parameters
ptrThe existing memory block

◆ osa_memcpy()

void* osa_memcpy ( void *  dest,
const void *  src,
size_t  n 
)

Copy from one memory area to another where the areas do not overlap

Parameters
destThe destination pointer
srcThe source pointer
nNumber of bytes to copy
Returns
A pointer to dest

◆ osa_memset()

void* osa_memset ( void *  src,
char  c,
size_t  n 
)
Parameters
srcThe memory area to fill
cThe constant byte to fill with
nNumber of bytes to fill
Returns
A pointer to dest

◆ osa_memmove()

void* osa_memmove ( void *  dest,
const void *  src,
size_t  n 
)

Copy from one memory area to another. Copying takes place as though the bytes in src are first copied into a temporary array that does not overlap src or dest, and the bytes are then copied from the temporary array to dest.

Parameters
destThe destination pointer
srcThe source pointer
nNumber of bytes to copy
Returns
A pointer to dest

◆ osa_set_memtype()

void osa_set_memtype ( void *  ptr,
uint32_t  type 
)

Use this API to set the allocating memory block's owner. This API should be called after succeeding to allocate memory.

Parameters
ptrThe existing memory block
typeThe module type of this memory block's owner
Return values
TRUE: success
FALSEfailure