exec.library: Compiler lint
[AROS.git] / rom / exec / allocpooled.c
blobcc1dd9f584fa6cf3d64931e50368b2b49caeed3d
1 /*
2 Copyright � 1995-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Allocate memory in a pool.
6 Lang: english
7 */
9 #include <aros/libcall.h>
11 #include "exec_intern.h"
12 #include "exec_util.h"
13 #include "memory.h"
15 #include "exec_debug.h"
16 #ifndef DEBUG_AllocPooled
17 # define DEBUG_AllocPooled 0
18 #endif
19 #undef DEBUG
20 #if DEBUG_AllocPooled
21 # define DEBUG 1
22 #endif
23 #include <aros/debug.h>
24 #undef kprintf
28 /*****************************************************************************
30 NAME */
31 #include <exec/memory.h>
32 #include <exec/memheaderext.h>
33 #include <proto/exec.h>
35 AROS_LH2(APTR, AllocPooled,
37 /* SYNOPSIS */
38 AROS_LHA(APTR, poolHeader, A0),
39 AROS_LHA(IPTR, memSize, D0),
41 /* LOCATION */
42 struct ExecBase *, SysBase, 118, Exec)
44 /* FUNCTION
45 Allocate memory out of a private memory pool.
47 INPUTS
48 poolHeader - Handle of the memory pool
49 memSize - Number of bytes you want to get
51 RESULT
52 A pointer to the number of bytes you wanted or NULL if the memory
53 couldn't be allocated
55 NOTES
57 EXAMPLE
59 BUGS
61 SEE ALSO
62 CreatePool(), DeletePool(), FreePooled()
64 INTERNALS
66 ******************************************************************************/
68 AROS_LIBFUNC_INIT
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;
76 if (mhe->mhe_Alloc)
77 return mhe->mhe_Alloc(mhe, memSize, &attributes);
78 else
79 return NULL;
81 else
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);
92 AROS_LIBFUNC_EXIT
94 } /* AllocPooled */