#include "DynAlloc.h"
Defines | |
#define | INCLUDE_FROM_DYNALLOC_C |
Functions | |
static uint8_t | Mem_GetBlockFlags (const Block_Number_t BlockNum) |
static void | Mem_SetBlockFlags (const Block_Number_t BlockNum, const uint8_t Flags) |
static void | Mem_Defrag (void) |
static bool | Mem_FindFreeBlocks (Block_Number_t *const RetStartPtr, const Block_Number_t Blocks) |
Mem_Handle_t | Mem_Alloc (const Alloc_Size_t Bytes) |
Mem_Handle_t | Mem_Realloc (Mem_Handle_t CurrAllocHdl, const Alloc_Size_t Bytes) |
Mem_Handle_t | Mem_Calloc (const Alloc_Size_t Bytes) |
void | Mem_Free (Mem_Handle_t CurrAllocHdl) |
Block_Number_t | Mem_TotalFreeBlocks (void) |
Handle_Number_t | Mem_TotalFreeHandles (void) |
Variables | |
struct { | |
char Mem_Heap [NUM_BLOCKS *BLOCK_SIZE] | |
void * Mem_Handles [NUM_HANDLES] | |
uint8_t Mem_Block_Flags [(NUM_BLOCKS/4)+((NUM_BLOCKS%4)?1:0)] | |
uint8_t FlagMaskLookupMask [4] | |
uint8_t FlagMaskLookupNum [4] | |
} | Mem_MemData |
#define INCLUDE_FROM_DYNALLOC_C |
Mem_Handle_t Mem_Alloc | ( | const Alloc_Size_t | Bytes | ) |
Allocates a given number of blocks from the heap (calculated from the requested number of bytes) and returns a handle to the newly allocated memory.
Bytes | The number of bytes requested to be allocated from the heap |
Mem_Handle_t Mem_Calloc | ( | const Alloc_Size_t | Bytes | ) |
Allocates a given number of blocks from the heap (calculated from the requested number of bytes) and returns a handle to the newly allocated memory. Calloced memory is automatically cleared to all 0x00 values at the time of allocation.
Bytes | The number of pre-cleared bytes requested to be allocated from the heap |
static void Mem_Defrag | ( | void | ) | [inline, static] |
static bool Mem_FindFreeBlocks | ( | Block_Number_t *const | RetStartPtr, | |
const Block_Number_t | Blocks | |||
) | [inline, static] |
void Mem_Free | ( | Mem_Handle_t | CurrAllocHdl | ) |
Deallocates a given previously allocated section of memory from the heap.
CurrAllocHdl | Handle to a previously allocated section of memory in the heap |
static uint8_t Mem_GetBlockFlags | ( | const Block_Number_t | BlockNum | ) | [static] |
Mem_Handle_t Mem_Realloc | ( | Mem_Handle_t | CurrAllocHdl, | |
const Alloc_Size_t | Bytes | |||
) |
Deallocates a given memory handle, and attempts to allocates the given number of blocks from the heap (calculated from the requested number of bytes) immediately following the deallocation. The new memory may be located in the same area as the previous memory, but this is not guaranteed.
CurrAllocHdl | Handle to an already allocated section of memory in the heap to deallocate | |
Bytes | The number of bytes requested to be allocated from the heap following the deallocation |
static void Mem_SetBlockFlags | ( | const Block_Number_t | BlockNum, | |
const uint8_t | Flags | |||
) | [static] |
Block_Number_t Mem_TotalFreeBlocks | ( | void | ) |
Returns the total number of unallocated blocks in the heap.
Handle_Number_t Mem_TotalFreeHandles | ( | void | ) |
Returns the total number of unallocated handles in the handle pool.
uint8_t FlagMaskLookupMask[4] |
uint8_t FlagMaskLookupNum[4] |
uint8_t Mem_Block_Flags[(NUM_BLOCKS/4)+((NUM_BLOCKS%4)?1:0)] |
void* Mem_Handles[NUM_HANDLES] |
char Mem_Heap[NUM_BLOCKS *BLOCK_SIZE] |
struct { ... } Mem_MemData |