2 Copyright � 1995-2012, 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.
48 poolHeader - Handle of the memory pool
49 memSize - Number of bytes you want to get
52 A pointer to the number of bytes you wanted or NULL if the memory
62 CreatePool(), DeletePool(), FreePooled()
66 ******************************************************************************/
70 struct MemHeaderExt
*mhe
= (struct MemHeaderExt
*)poolHeader
;
72 if (mhe
->mhe_MemHeader
.mh_Attributes
& MEMF_MANAGED
)
74 ULONG attributes
= (ULONG
)(IPTR
)mhe
->mhe_MemHeader
.mh_First
;
77 return mhe
->mhe_Alloc(mhe
, memSize
, &attributes
);
83 struct TraceLocation tp
= CURRENT_LOCATION("AllocPooled");
84 struct Pool
*pool
= poolHeader
+ MEMHEADER_TOTAL
;
86 D(bug("AllocPooled 0x%P memsize %u by \"%s\"\n", poolHeader
, memSize
, SysBase
->ThisTask
->tc_Node
.ln_Name
));
88 /* Allocate from the specified pool with flags stored in pool header */
89 return InternalAllocPooled(poolHeader
, memSize
, pool
->Requirements
, &tp
, SysBase
);