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

Go to the source code of this file.

Functions

JUNO_STATUS_T Juno_MemoryBlkInit (JUNO_MEMORY_BLOCK_T *ptMemBlk, void *pvMemory, JUNO_MEMORY_BLOCK_METADATA_T *pvMetadata, size_t zTypeSize, size_t zLength, JUNO_FAILURE_HANDLER_T pfcnFailureHandler, JUNO_USER_DATA_T *pvUserData)
 Initializes a memory block for allocation. Sets up a memory block with an associated free stack for managing fixed-size allocations.
 
JUNO_STATUS_T Juno_MemoryGet (JUNO_MEMORY_ALLOC_T *ptMem, JUNO_MEMORY_T *ptMemory, size_t zSize)
 Generic memory allocation function. Allocates memory by using the appropriate allocation method based on the allocation type.
 
JUNO_STATUS_T Juno_MemoryUpdate (JUNO_MEMORY_ALLOC_T *ptMem, JUNO_MEMORY_T *ptMemory, size_t zNewSize)
 Updates the current memory allocation to a new size (realloc).
 
JUNO_STATUS_T Juno_MemoryPut (JUNO_MEMORY_ALLOC_T *ptMem, JUNO_MEMORY_T *ptMemory)
 Generic memory free function. Releases memory back to the allocator and clears the memory descriptor.
 
const JUNO_MEMORY_API_TJuno_MemoryApi (void)
 Retrieves the generic memory API structure.
 

Function Documentation

◆ Juno_MemoryApi()

const JUNO_MEMORY_API_T * Juno_MemoryApi ( void  )

Retrieves the generic memory API structure.

Returns
Pointer to the generic memory API structre.

◆ Juno_MemoryBlkInit()

JUNO_STATUS_T Juno_MemoryBlkInit ( JUNO_MEMORY_BLOCK_T ptMemBlk,
void *  pvMemory,
JUNO_MEMORY_BLOCK_METADATA_T pvMetadata,
size_t  zTypeSize,
size_t  zLength,
JUNO_FAILURE_HANDLER_T  pfcnFailureHandler,
JUNO_USER_DATA_T pvUserData 
)

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.

◆ Juno_MemoryGet()

JUNO_STATUS_T Juno_MemoryGet ( JUNO_MEMORY_ALLOC_T ptMem,
JUNO_MEMORY_T ptMemory,
size_t  zSize 
)

Generic memory allocation function. Allocates memory by using the appropriate allocation method based on the allocation type.

Parameters
ptMemPointer to the memory allocation structure.
ptMemoryPointer to a memory descriptor where allocation details will be stored.
Returns
JUNO_STATUS_T Status of the allocation.

◆ Juno_MemoryPut()

JUNO_STATUS_T Juno_MemoryPut ( JUNO_MEMORY_ALLOC_T ptMem,
JUNO_MEMORY_T ptMemory 
)

Generic memory free function. Releases memory back to the allocator and clears the memory descriptor.

Parameters
ptMemPointer to the memory allocation structure.
ptMemoryPointer to the memory descriptor to free.
Returns
JUNO_STATUS_T Status of the free operation.

◆ Juno_MemoryUpdate()

JUNO_STATUS_T Juno_MemoryUpdate ( JUNO_MEMORY_ALLOC_T ptMem,
JUNO_MEMORY_T ptMemory,
size_t  zNewSize 
)

Updates the current memory allocation to a new size (realloc).

Parameters
ptMemPointer to the memory allocator.
ptMemoryThe memory to update with a new size.
zNewSizeThe new size of the memory.
Returns
JUNO_STATUS_T Status of the allocation.