| M E M _ A T T A C H H O T V E C ( )
| | | | | SOURCE: qdev_autodocs.txt 1.163 (12/09/2014) English
AMIGA - MEM_#?
----------------------------------------------------------------------------
NAME
mem_attachhotvec() - Allocates and attaches hot vector
array to current task.
SYNOPSIS
hot = mem_attachhotvec(id, size);
void *mem_attachhotvec(ULONG, LONG);
FUNCTION
This func. allocates and attaches "hot vector" array to a
task so that programmer can pass pointers of variables to
callbacks/hooks that do not take data pointer. All within
current task.
INPUTS
id - Unique hot vector identification number (32 bit).
Please use values in range from 0x00400000 to
0x7FFFFFFF. Do not use value of 0 at all or you
may encounter false matches!
size - Size of the array. Stuffing anything below 4 will
result in an array of at least 4 vectors.
RETURNS
Function returns pointer to MemList or NULL upon failure.
Member 'ml_ME[0].me_Addr' points at the vector root data.
BASES
SysBase
NOTES
This function links hot vector against 'tc_MemEntry' list
of current task so you may skip 'mem_detachhotvec()' and
the memory will still be deallocated upon task or process
death. But to keep up with good programming practices do
that only when you aboslutely have to.
Func. may fail if there is not enough memory but will not
fail if selected 'id' is collisious! This is to allow new
hot vector to overlay the existing one. Useful.
Function applies MEMF_CLEAR automatically so vectors are
all zeroed.
Do not use id values below 0x00400000. They are reserved
for 'qdev' routines!
Do not use id values above 0x7FFFFFFF. They are intended
for relative id allocation! Yes, that is possible.
SEE ALSO
mem_attachrelhotvec(), mem_detachhotvec(),
mem_obtainhotvec(), mem_obtainrelhotvec(),
mem_resolvehotvec()
EXAMPLE
...
void *hot;
LONG **vec;
/*
* Allocate hot vector of 16 vectors giving it an id of
* 0x00400000.
*/
if ((hot = mem_attachhotvec(0x00400000, 16)))
{
/*
* Obtain address to top of the hot vector by passing
* 0. Now you setup the array so that further call to
* this func loads it in a callback for instance.
*/
vec = mem_obtainhotvec(0x00400000, 0);
vec[0] = (LONG *)<my addr 1>;
vec[1] = (LONG *)<my addr 2>;
...
mem_detachhotvec(hot);
}
...
BUGS
Maybe not a bug, but a design principle. You must really
take care of id collision before it happens. And that is
quite difficult task if you do not know of any other hot
vectors. Thus please use the 'mem_attachrelhotvec()' and
'mem_obtainrelhotvec()' instead. Thank you!
----------------------------------------------------------------------------
| |
| |