2 Copyright � 1995-2013, The AROS Development Team. All rights reserved.
5 Desc: Allocate memory in a pool.
9 #include <aros/libcall.h>
11 #include "exec_intern.h"
12 #include "exec_util.h"
15 #include "exec_debug.h"
16 #ifndef DEBUG_AllocPooled
17 # define DEBUG_AllocPooled 0
23 #include <aros/debug.h>
28 /*****************************************************************************
31 #include <exec/memory.h>
32 #include <exec/memheaderext.h>
33 #include <proto/exec.h>
35 AROS_LH2(APTR
, AllocPooled
,
38 AROS_LHA(APTR
, poolHeader
, A0
),
39 AROS_LHA(IPTR
, memSize
, D0
),
42 struct ExecBase
*, SysBase
, 118, Exec
)
45 Allocate memory out of a private memory pool. The memory must be
46 freed with FreePooled(), or by deallocating the entire pool with
50 poolHeader - Handle of the memory pool
51 memSize - Number of bytes you want to get
54 A pointer to the number of bytes you wanted or NULL if the memory
64 CreatePool(), DeletePool(), FreePooled()
68 ******************************************************************************/
72 struct MemHeaderExt
*mhe
= (struct MemHeaderExt
*)poolHeader
;
74 if (IsManagedMem(mhe
))
76 ULONG attributes
= (ULONG
)(IPTR
)mhe
->mhe_MemHeader
.mh_First
;
79 return mhe
->mhe_Alloc(mhe
, memSize
, &attributes
);
85 struct TraceLocation tp
= CURRENT_LOCATION("AllocPooled");
86 struct Pool
*pool
= poolHeader
+ MEMHEADER_TOTAL
;
88 D(bug("AllocPooled 0x%P memsize %u by \"%s\"\n", poolHeader
, memSize
, SysBase
->ThisTask
->tc_Node
.ln_Name
));
90 /* Allocate from the specified pool with flags stored in pool header */
91 return InternalAllocPooled(poolHeader
, memSize
, pool
->Requirements
, &tp
, SysBase
);