Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Creates a Allocates memory from specified segment. Returned memory block will be aligned on a CPU word boundary.

Files

lib_mem.h/lib_mem.c

Prototype

Code Block
LanguageC++
CaptionTextCAPTION
languagecpp
          void  *Mem_SegCreateSegAlloc (const  CPU_CHAR    *p_name,
	 
                                MEM_SEG     *p_seg,
 
                                    CPU_ADDR     seg_base_addr,
                                      CPU_SIZE_T   size,
                                      CPU_SIZE_T   padding_align,

                                     LIB_ERR     *p_err);

Arguments

p_name

Pointer to segment nameallocated object name. Used for allocations tracking. May be DEF_NULL.

p_seg

Pointer to segment data . Must be allocated by caller.

seg_base_addr

Address of segment's first byte.

size

Total size of segment, in bytes.

padding_align

Padding alignment, in bytes, that will be added to any allocated buffer from this memory segment. MUST be a power of 2. LIB_MEM_SEG_PADDING_ALIGN_NONE means no padding.from which to allocate memory.

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_SEGMEM_SIZE

LIB_MEM_ERR_INVALID_MEM_ALIGN

LIB_MEM_ERR_NULL_PTR

LIB_MEM_ERR_INVALID_SEG_OVERLAPLIB_MEM_ERR_INVALID_SEG_EXISTSOVF

Returned Value

NonePointer to allocated memory block, if successful.

DEF_NULL, otherwise.

Required Configuration

None.

Notes / Warnings

  1. New segments are checked for overlap with existing segments. A critical section needs to be maintained during the whole list search and add procedure to prevent a reentrant call from creating another segment overlapping with the one being added

    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() or Mem_SegAllocHW().