Main Page | Modules | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

Malloc - Memory management


Files

file  otMalloc.h
 Multi-heap memory management library for otStudio.

Modules

 Version History

Defines

#define OT_FAST_HEAP1_SIZE   (4U * 1024U)
#define OT_FAST_HEAP2_SIZE   (15U * 1024U)
#define OT_FAST_BANK_NONE   0
#define OT_FAST_BANK_1   1
#define OT_FAST_BANK_2   2

Functions

void _initMalloc ()
 Initialize the historical normal heap. Call once during setup().
U32 _memFree ()
 Return currently allocatable bytes in the normal heap.
void * _malloc (U32 size)
 Allocate memory from the normal heap.
void * _calloc (U32 size)
 Allocate and zero-initialize memory from the normal heap.
void * _realloc (void *ptr, U32 size)
 Reallocate a block from the normal heap.
void * _reallocf (void *ptr, U32 size)
 Reallocate and free the original block on failure.
void _free (void *ptr)
 Free a block allocated by the normal heap.
void _initFastMalloc ()
 Initialize the two built-in fast heaps.
void _initFastMallocRegions (void *bank1Start, U32 bank1Size, void *bank2Start, U32 bank2Size)
 Initialize the fast allocator with caller-supplied regions.
char _fastMallocReady ()
 Return non-zero when at least one fast heap is available.
void * _fastMalloc1 (U32 size)
 Allocate from fast Bank 1 only. Returns null when it does not fit.
void * _fastMalloc2 (U32 size)
 Allocate from fast Bank 2 only. Returns null when it does not fit.
void * _fastMalloc (U32 size)
 Allocate from either fast bank.
void * _fastCalloc1 (U32 size)
 Zero-initialized equivalents of the fast allocation functions.
void * _fastCalloc2 (U32 size)
void * _fastCalloc (U32 size)
void _fastFree (void *ptr)
 Free a block allocated by any fast heap.
U32 _fastMemFree1 ()
 Return free bytes in fast Bank 1 / Bank 2.
U32 _fastMemFree2 ()
U32 _fastMemLargest1 ()
 Return the largest currently allocatable block in each fast bank.
U32 _fastMemLargest2 ()
int _fastMemBank (const void *ptr)
 Identify the fast bank containing ptr.

Define Documentation

#define OT_FAST_BANK_1   1
 

#define OT_FAST_BANK_2   2
 

#define OT_FAST_BANK_NONE   0
 

#define OT_FAST_HEAP1_SIZE   (4U * 1024U)
 

#define OT_FAST_HEAP2_SIZE   (15U * 1024U)
 


Function Documentation

void* _calloc (  U32  size  ) 
 

void* _fastCalloc (  U32  size  ) 
 

void* _fastCalloc1 (  U32  size  ) 
 

void* _fastCalloc2 (  U32  size  ) 
 

void _fastFree (  void *  ptr  ) 
 

void* _fastMalloc (  U32  size  ) 
 

The allocator chooses a bank that can satisfy the request while attempting to preserve the other bank. No fallback to the normal heap is performed here; that policy belongs to the caller.

void* _fastMalloc1 (  U32  size  ) 
 

void* _fastMalloc2 (  U32  size  ) 
 

char _fastMallocReady (   ) 
 

int _fastMemBank (  const void *  ptr  ) 
 

Returns:
OT_FAST_BANK_1, OT_FAST_BANK_2 or OT_FAST_BANK_NONE.

U32 _fastMemFree1 (   ) 
 

U32 _fastMemFree2 (   ) 
 

U32 _fastMemLargest1 (   ) 
 

U32 _fastMemLargest2 (   ) 
 

void _free (  void *  ptr  ) 
 

void _initFastMalloc (   ) 
 

The built-in arenas are emitted into GCC Blackfin sections .l1.data.A and .l1.data.B. The sizes are controlled by OT_FAST_HEAP1_SIZE and OT_FAST_HEAP2_SIZE.

void _initFastMallocRegions (  void *  bank1Start,
U32  bank1Size,
void *  bank2Start,
U32  bank2Size
) 
 

This alternative is useful when a custom linker script already reserves the L1 regions. Passing a null pointer or zero size disables that bank.

void _initMalloc (   ) 
 

void* _malloc (  U32  size  ) 
 

U32 _memFree (   ) 
 

void* _realloc (  void *  ptr,
U32  size
) 
 

void* _reallocf (  void *  ptr,
U32  size
) 
 

footer

otStudio - Library Reference - (C) 2020-25 Officina Turini, All Rights Reserved
Document built with Doxygen 1.4.0