Autodocs Static lib:
amiga.lib ACrypt AddTOF ArgArrayDone ArgArrayInit ArgInt ArgString BeginIO CallHook CallHookA CheckRexxMsg CoerceMethod CoerceMethodA CreateExtIO CreatePort CreateStdIO CreateTask CxCustom CxDebug CxFilter CxSender CxSignal CxTranslate DeleteExtIO DeletePort DeleteStdIO DeleteTask DoMethod DoMethodA DoSuperMethod DoSuperMethodA FastRand FreeIEvents GetRexxVar HookEntry HotKey InvertString LibAllocPooled LibCreatePool LibDeletePool LibFreePooled NewList RangeRand RemTOF SetRexxVar SetSuperAttrs TimeDelay afp arnd dbf fpa printf sprintf stdio Include GuruMeditation
|
Docs » Autodocs » amiga.lib » LibAllocPooled
LibAllocPooled -- Allocate memory with the pool manager (V33)
memory=LibAllocPooled(poolHeader,memSize) d0 a0 d0 void *LibAllocPooled(void *,ULONG);
This function is a copy of the pool functions in V39 and up of EXEC. In fact, if you are running in V39, this function will notice and call the EXEC function. This function works in V33 and up (1.2) Amiga system. The C code interface is _LibAllocPooled() and takes its arguments from the stack just like the C code interface for AllocPooled() in amiga.lib. The assembly code interface is with the symbol _AsmAllocPooled: and takes the parameters in registers with the additional parameter of ExecBase being in a6 which can be used from SAS/C 6 by a prototype of: void * __asm AsmAllocPooled(register __a0 void *, register __d0 ULONG, register __a6 struct ExecBase *); Allocate memSize bytes of memory, and return a pointer. NULL is returned if the allocation fails. Doing a LibDeletePool() on the pool will free all of the puddles and thus all of the allocations done with LibAllocPooled() in that pool. (No need to LibFreePooled() each allocation)
memSize - the number of bytes to allocate poolHeader - a specific private pool header.
A pointer to the memory, or NULL. The memory block returned is long word aligned.
The pool function do not protect an individual pool from multiple accesses. The reason is that in most cases the pools will be used by a single task. If your pool is going to be used by more than one task you must Semaphore protect the pool from having more than one task trying to allocate within the same pool at the same time. Warning: Forbid() protection *will not work* in the future. *Do NOT* assume that we will be able to make it work in the future. LibAllocPooled() may well break a Forbid() and as such can only be protected by a semaphore. To track sizes yourself, the following code can be used: *Assumes a6=ExecBase* ; ; Function to do AllocVecPooled(Pool,memSize) ; AllocVecPooled: addq.l #4,d0 ; Get space for tracking move.l d0,-(sp) ; Save the size jsr LibAllocPooled ; Call pool... move.l (sp)+,d1 ; Get size back... tst.l d0 ; Check for error beq.s avp_fail ; If NULL, failed! move.l d0,a0 ; Get pointer... move.l d1,(a0)+ ; Store size move.l a0,d0 ; Get result avp_fail: rts ; return ; ; Function to do LibFreeVecPooled(pool,memory) ; FreeVecPooled: move.l -(a1),d0 ; Get size / ajust pointer jmp LibFreePooled
FreePooled, CreatePool, DeletePool, LibFreePooled(), LibCreatePool(), LibDeletePool()
|