Versions Compared

Key

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

Creates a Allocates memory from specified segment. The returned buffer will be padded in function of memory segment's properties.

Files

lib_mem.h/lib_mem.c

Prototype

Code Block
LanguageC++
CaptionTextCAPTION
languagecpp
          void  *Mem_SegCreateSegAllocHW (const  CPU_CHAR    *p_name,
	 
                                MEM_SEG     *p_seg,
      
                               CPU_ADDRSIZE_T     seg_base_addrsize,
                                      CPU_SIZE_T   sizealign,

                                     CPU_SIZE_T   padding_align*p_bytes_reqd,
                                      LIB_ERR     *p_err);

Arguments

p_name

Pointer to segment allocated 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 bytefrom which to allocate memory.

size

Total size of segmentSize of memory block to allocate, in bytes.

padding_align

Padding Required alignment of memory block, in bytes, that will be added to any allocated buffer from this memory segment. MUST be a power of 2. LIB

p_

...

bytes_reqd

Pointer to variable that will receive the number of free bytes missing for the allocation to succeed. Set to DEF_NULL to skip calculation.

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_OVERLAP

LIB_MEM_ERR_INVALID_SEG_EXISTS

OVF

Returned Value

NonePointer to allocated memory block, if successful.

DEF_NULL, otherwise.

Required Configuration

None.

Notes / Warnings

...

None.