As with memory lists, tasks can only use memory pools that they own. This means that the system-wide free memory pool is off-limits to tasks, as are memory pools belonging to other tasks.
InitList()
function:
void InitList(List *l, const char *name)
AddHead()
function:
void AddHead(List *l, Node *n)
AllocMemFromMemLists()
function:
void *AllocMemFromMemLists( List *l, int32 size, uint32 memflags )
l
argument is the free memory pool from which to allocate a memory block. As noted earlier, this pool must be owned by the calling task. The size
argument specifies the size of the block to allocate, in bytes.
The memflags
argument specifies the type of memory to allocate, the alignment of the block with respect to the page, and so on; these flags can include MEMTYPE_ANY
, MEMTYPE_VRAM
, MEMTYPE_DRAM
, MEMTYPE_BANKSELECT
, MEMTYPE_BANK1
, MEMTYPE_BANK2
, MEMTYPE_DMA
, MEMTYPE_CEL
, MEMTYPE_AUDIO
, MEMTYPE_DSP
, MEMTYPE_FILL
, MEMTYPE_INPAGE
, MEMTYPE_SYSTEMPAGESIZE
, MEMTYPE_STARTPAGE
, and MEMTYPE_MYPOOL
. For complete descriptions of these flags, see Allocating a Memory Block. The function returns a pointer to the block that was allocated, or NULL if there was not enough memory in the list to satisfy the request.
To free memory that you've allocated with AllocMemFromMemLists(),
you
can only use FreeMemToMemLists()
(described in the next section). Each
memory allocation function has a corresponding deallocation function; if you use another memory allocation function, you must use its corresponding deallocation function.
AllocMemFromMemLists(),
you use
the FreeMemToMemLists()
function:
void FreeMemToMemLists( List *l, void *p, int32 size )
l
argument is a pointer to the memory pool from which the block was allocated. The p
argument is a pointer to the block to free. The size
argument is the size of the block to free, in bytes.