MEM_free
2-222
C Interface
Syntax
status = MEM_free(segid, addr, size);
Parameters
Int
segid;
/* memory segment identifier */
Ptr
addr;
/* block address pointer */
size_t
size;
/* block length in MADUs*/
Return Value
Bool
status;
/* TRUE if successful */
Description
MEM_free places the memory block specified by addr and size back into
the free pool of the segment specified by segid. The newly freed block is
combined with any adjacent free blocks. This space is then available for
further allocation by MEM_alloc. The segid can be an integer or a
memory segment name defined in the configuration.
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_free cannot be called from the context of a SWI or HWI.
Although MEM_free combines newly freed blocks with adjacent free
blocks, it does not combine blocks that cross a 64K page boundary. See
the MEM_alloc topic for information about the effects of page boundaries
on heaps.
Constraints and
Calling Context
❏
addr must be a valid pointer returned from a call to MEM_alloc.
❏
segid and size are those values used in a previous call to MEM_alloc.
❏
MEM_free cannot be called by HWI or SWI functions.
❏
MEM_free cannot be called if the TSK scheduler is disabled.
See Also
MEM_alloc
std.h and stdlib.h functions
MEM_free
Free a block of memory