graphics.library: MakeVPort() RastInfo based double-buffering fixes
[AROS.git] / rom / exec / allocvec.c
blobae183e17e12af7dbbe71d5aed3078d2e8914a860
1 /*
2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Allocate some memory.
6 Lang: english
7 */
8 #include "exec_intern.h"
9 #include <aros/libcall.h>
10 #include "memory.h"
11 #include <proto/exec.h>
13 /*****************************************************************************
15 NAME */
17 AROS_LH2(APTR, AllocVec,
19 /* SYNOPSIS */
20 AROS_LHA(IPTR, byteSize, D0),
21 AROS_LHA(ULONG, requirements, D1),
23 /* LOCATION */
24 struct ExecBase *, SysBase, 114, Exec)
26 /* FUNCTION
27 Allocate some memory from the sytem memory pool with the given
28 requirements and without the need to memorize the actual size
29 of the block.
31 INPUTS
32 byteSize - Number of bytes you want to get
33 requirements - Type of memory
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 FreeVec()
48 INTERNALS
50 ******************************************************************************/
52 AROS_LIBFUNC_INIT
54 UBYTE *ret;
56 /* Add room for stored size. */
57 byteSize+=AROS_ALIGN(sizeof(IPTR));
59 /* Get the memory. */
60 ret=(UBYTE *)AllocMem(byteSize,requirements);
62 /* If there's not enough memory left return immediately. */
63 if(ret==NULL)
64 return NULL;
66 /* Store size */
67 *(IPTR *)ret=byteSize;
69 /* return free space */
70 return ret+AROS_ALIGN(sizeof(IPTR));
71 AROS_LIBFUNC_EXIT
72 } /* AllocVec */