| M E M _ G E T M E M C L U S T E R ( )
| | | | | SOURCE: qdev_autodocs.txt 1.163 (12/09/2014) English
PORTA - MEM_#?
----------------------------------------------------------------------------
NAME
mem_getmemcluster() - Obtains pointer to a chunk from
the given cluster.
SYNOPSIS
mem = mem_getmemcluster(ptr);
void *mem_getmemcluster(void *);
FUNCTION
This func. gets pointer to free chunk from the cluster.
INPUTS
ptr - Cluster pointer.
RETURNS
Function will return pointer to the mem. whose size was
set in 'mem_alloccluster()' or NULL if there is no free
chunks left.
BASES
SysBase
NOTES
Use this function if you need to allocate lots of small
and always equal portions of memory frequently as this
function really prevents heavy mem. fragmentation plus
it is much faster than 'AllocMem()' alone!
Keep in mind that MEMF_CLEAR is only valid for chunks
that were obtained for a first time. Releasing them and
obtaining once again does not clear the memory!
SEE ALSO
mem_alloccluster(), mem_freecluster(),
mem_freememcluster()
EXAMPLE
...
void *cluster;
void *ptra;
void *ptrb;
/*
* This will alloc. 8 chunks 32 bytes each in one block.
*/
if ((cluster = mem_alloccluster(32, 8, MEMF_PUBLIC)))
{
/*
* Now you can use that chunk area, eg. 32 bytes!
*/
if ((ptra = mem_getmemcluster(cluster)))
{
/*
* And another...
*/
if ((ptrb = mem_getmemcluster(cluster)))
{
...
/*
* Please note that deallocating chunks who wont
* be freed during runtime is not necessary as
* last call will clean it all up.
*/
mem_freememcluster(ptrb);
}
mem_freememcluster(ptra);
}
mem_freecluster(cluster);
}
BUGS
None known.
----------------------------------------------------------------------------
| |
| |