try to make sure compiler/include/mmakefile is always refreshed correctly.
[AROS.git] / rom / exec / allocvecpooled.c
blob95f945ee350654404e48b3c95467023f4fdb5e26
1 /*
2 Copyright � 2003-2013, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/libcall.h>
7 #include "exec_intern.h"
8 #include <aros/debug.h>
10 /*****************************************************************************
12 NAME */
13 #include <exec/memory.h>
14 #include <exec/memheaderext.h>
15 #include <proto/exec.h>
17 AROS_LH2(APTR, AllocVecPooled,
19 /* SYNOPSIS */
20 AROS_LHA(APTR, poolHeader, A0),
21 AROS_LHA(IPTR, memSize, D0),
23 /* LOCATION */
24 struct ExecBase *, SysBase, 169, Exec)
26 /* FUNCTION
27 Allocate memory out of a private memory pool and remember the size.
28 The memory must be freed with FreeVecPooled(), or by deallocating
29 the entire pool with DeletePool().
31 INPUTS
32 poolHeader - Handle of the memory pool
33 memSize - Number of bytes you want to get
35 RESULT
36 A pointer to the number of bytes you wanted or NULL if the memory
37 couldn't be allocated
39 NOTES
41 EXAMPLE
43 BUGS
45 SEE ALSO
46 CreatePool(), DeletePool(), FreeVecPooled()
48 INTERNALS
50 ******************************************************************************/
52 AROS_LIBFUNC_INIT
54 struct MemHeaderExt *mhe = (struct MemHeaderExt *)poolHeader;
56 /* 0-sized allocation results in returning NULL (API guarantee) */
57 if(!memSize)
58 return NULL;
60 if (IsManagedMem(mhe))
62 ULONG poolrequirements = (ULONG)(IPTR)mhe->mhe_MemHeader.mh_First;
64 if (mhe->mhe_Alloc)
65 return mhe->mhe_AllocVec(mhe, memSize, &poolrequirements);
66 else
67 return NULL;
69 else
71 IPTR *memory;
73 if (poolHeader == NULL) return NULL;
75 memSize += sizeof(IPTR);
76 memory = AllocPooled(poolHeader, memSize);
78 if (memory != NULL)
80 *memory++ = memSize;
83 return memory;
86 AROS_LIBFUNC_EXIT
87 } /* AllocVecPooled() */