MEM_valloc
2-228
C Interface
Syntax
addr = MEM_valloc(segid, size, align, value);
Parameters
Int
segid;
/* memory segment identifier */
size_t
size;
/* block size in MADUs */
size_t
align;
/* block alignment */
Char
value;
/* character value */
Return Value
Void
*addr;
/* address of allocated block of memory */
Description
MEM_valloc uses MEM_alloc to allocate the memory before initializing it
to value.
The segid parameter identifies the memory segment from which memory
is to be allocated. This identifier can be an integer or a memory segment
name defined in the configuration. The files created by the configuration
define each configured segment name as a variable with an integer
value.
The block contains size MADUs and starts at an address that is a multiple
of align. If align is 0 or 1, there is no alignment constraint.
If the memory request cannot be satisfied, MEM_valloc calls SYS_error
with SYS_EALLOC and returns MEM_ILLEGAL.
MEM functions that allocate and deallocate memory internally lock the
memory by calling the LCK_pend and LCK_post functions. If another task
already holds a lock to the memory, there is a context switch. For this
reason, MEM_valloc cannot be called from the context of a SWI or HWI.
Constraints and
Calling Context
❏
segid must identify a valid memory segment.
❏
MEM_valloc cannot be called from a SWI or HWI.
❏
MEM_valloc cannot be called if the TSK scheduler is disabled.
❏
align must be 0, or a power of 2 (for example, 1, 2, 4, 8).
See Also
MEM_alloc
MEM_calloc
MEM_free
SYS_error
std.h and stdlib.h functions
MEM_valloc
Allocate from a memory segment and set value