The pool functions 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:
protection *will not work* in the future. *Do NOT* assume that we will be able to make it work in the future. AllocPooled() may well break a
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:
tst.l d0 ; Size must be > 0
beq.s avp_fail ; If zero, failed!
addq.l #4,d0 ; Get space for tracking
bcs.s avp_overflow ; Total size too large?
move.l d0,-(sp) ; Save the size
jsr _LVOAllocPooled(a6) ; 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
avp_overflow: moveq.l #0,d0
;
; Function to do FreeVecPooled(pool,memory)
;
FreeVecPooled: move.l a1,d0 ; Memory must not be NULL
beq.s fvp_ignore
move.l -(a1),d0 ; Get size / adjust pointer
jsr _LVOFreePooled(a6)
fvp_ignore: rts