LibJuno 0.42.0
LibJuno is a lightweight C99 library designed specifically for embedded systems.
Loading...
Searching...
No Matches
memory_block.h File Reference
#include "juno/module.h"
#include "juno/status.h"
#include "juno/memory/memory_api.h"
Include dependency graph for memory_block.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define JUNO_MEMORY_BLOCK(name, type, length)   static type name[length] = {0}
 Macro to declare a static memory block and its associated free stack.
 
#define JUNO_MEMORY_BLOCK_METADATA(name, length)   static JUNO_MEMORY_BLOCK_METADATA_T name[length] = {0}
 Macro to declare a static array for memory metadata.
 

Typedefs

typedef struct JUNO_MEMORY_BLOCK_METADATA_TAG JUNO_MEMORY_BLOCK_METADATA_T
 
typedef struct JUNO_MEMORY_BLOCK_TAG JUNO_MEMORY_BLOCK_T
 
typedef struct JUNO_MEMORY_ALLOC_BLOCK_TAG JUNO_MEMORY_ALLOC_BLOCK_T
 

Functions

struct JUNO_MEMORY_ALLOC_BLOCK_TAG JUNO_MODULE_DERIVE (JUNO_MEMORY_ALLOC_ROOT_T, uint8_t *pvMemory;JUNO_MEMORY_BLOCK_METADATA_T *ptMetadata;size_t zTypeSize;size_t zLength;size_t zUsed;size_t zFreed;)
 
union JUNO_MEMORY_ALLOC_TAG JUNO_MODULE (JUNO_MEMORY_ALLOC_API_T, JUNO_MEMORY_ALLOC_ROOT_T, JUNO_MEMORY_ALLOC_BLOCK_T tJunoMemoryBlock;)
 
JUNO_STATUS_T JunoMemory_BlockApi (JUNO_MEMORY_ALLOC_T *ptJunoMemory, void *pvMemory, JUNO_MEMORY_BLOCK_METADATA_T *ptMetadata, size_t zTypeSize, size_t zLength, JUNO_FAILURE_HANDLER_T pfcnFailureHandler, JUNO_USER_DATA_T *pvFailureUserData)
 Initializes a memory block for allocation. Sets up a memory block with an associated free stack for managing fixed-size allocations.
 

Macro Definition Documentation

◆ JUNO_MEMORY_BLOCK

#define JUNO_MEMORY_BLOCK (   name,
  type,
  length 
)    static type name[length] = {0}

Macro to declare a static memory block and its associated free stack.

This API has been generated by LibJuno: https://www.robinonsay.com/libjuno/ This header contains the juno_memory block blockementation

Author
Parameters
nameName of the memory block.
typeData type of each block element.
lengthNumber of elements in the memory block.

◆ JUNO_MEMORY_BLOCK_METADATA

#define JUNO_MEMORY_BLOCK_METADATA (   name,
  length 
)    static JUNO_MEMORY_BLOCK_METADATA_T name[length] = {0}

Macro to declare a static array for memory metadata.

Parameters
nameName of the metadata array.
lengthNumber of metadata entries.

Typedef Documentation

◆ JUNO_MEMORY_ALLOC_BLOCK_T

typedef struct JUNO_MEMORY_ALLOC_BLOCK_TAG JUNO_MEMORY_ALLOC_BLOCK_T

◆ JUNO_MEMORY_BLOCK_METADATA_T

◆ JUNO_MEMORY_BLOCK_T

typedef struct JUNO_MEMORY_BLOCK_TAG JUNO_MEMORY_BLOCK_T

Function Documentation

◆ JUNO_MODULE()

union JUNO_MEMORY_ALLOC_TAG JUNO_MODULE ( JUNO_MEMORY_ALLOC_API_T  ,
JUNO_MEMORY_ALLOC_ROOT_T  ,
JUNO_MEMORY_ALLOC_BLOCK_T tJunoMemoryBlock;   
)

This is the default blockementation for JUNO_MEMORY_T. If you want to derive new blockementations for JUNO_MEMORY_T use #define JUNO_MEMORY_DERIVED prior to including #include "juno_memory_block.h"

Note: If you are blockementing a derived module you will need to blockement JUNO_MEMORY_BLOCK.

◆ JUNO_MODULE_DERIVE()

struct JUNO_MEMORY_ALLOC_BLOCK_TAG JUNO_MODULE_DERIVE ( JUNO_MEMORY_ALLOC_ROOT_T  ,
uint8_t *pvMemory;JUNO_MEMORY_BLOCK_METADATA_T *ptMetadata;size_t zTypeSize;size_t zLength;size_t zUsed;size_t zFreed;   
)

◆ JunoMemory_BlockApi()

JUNO_STATUS_T JunoMemory_BlockApi ( JUNO_MEMORY_ALLOC_T ptJunoMemory,
void *  pvMemory,
JUNO_MEMORY_BLOCK_METADATA_T ptMetadata,
size_t  zTypeSize,
size_t  zLength,
JUNO_FAILURE_HANDLER_T  pfcnFailureHandler,
JUNO_USER_DATA_T pvFailureUserData 
)

Initializes a memory block for allocation. Sets up a memory block with an associated free stack for managing fixed-size allocations.

Parameters
ptMemBlkPointer to the memory block structure to initialize.
pvMemoryPointer to the contiguous memory used for allocations.
pvMetadataPointer to an array for block metadata tracking.
zTypeSizeSize in bytes of each element in the block.
zLengthTotal number of possible allocations.
pfcnFailureHandlerCallback function to handle failures.
pvUserDataUser data passed to the failure handler.
Returns
JUNO_STATUS_T Status of the initialization.