Mem_SegAlloc()
Allocates memory from specified segment. Returned memory block will be aligned on a CPU word boundary.
Files
lib_mem.h/lib_mem.c
Prototype
void *Mem_SegAlloc (const CPU_CHAR *p_name, MEM_SEG *p_seg, CPU_SIZE_T size, LIB_ERR *p_err)
Arguments
p_name
Pointer to allocated object name. Used for allocations tracking. May be DEF_NULL
.
p_seg
Pointer to segment data from which to allocate memory. Passing DEF_NULL
will allocate memory from the general-purpose heap.
size
Size of memory block to allocate, in bytes.
p_err
Pointer to variable that will receive the return error code from this function.
LIB_MEM_ERR_NONE
LIB_MEM_ERR_INVALID_MEM_SIZE
LIB_MEM_ERR_INVALID_MEM_ALIGN
LIB_MEM_ERR_NULL_PTR
LIB_MEM_ERR_SEG_OVF
Returned Value
Pointer to allocated memory block, if successful.
DEF_NULL, otherwise.
Required Configuration
None.
Notes / Warnings
The memory block returned by this function will be aligned on a word boundary. In order to specify a specific alignment value, use either
Mem_SegAllocExt()
orMem_SegAllocHW()
.- For an usage example of this function, refer to Memory Segments page.