2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
8 #include "__arosc_privdata.h"
14 #include <exec/memory.h>
15 #include <proto/exec.h>
16 #include <aros/symbolsets.h>
17 #include <aros/debug.h>
19 /*****************************************************************************
30 Allocate size bytes of memory and return the address of the
34 size - How much memory to allocate.
37 A pointer to the allocated memory or NULL. If you don't need the
38 memory anymore, you can pass this pointer to free(). If you don't,
39 the memory will be freed for you when the application exits.
42 This function must not be used in a shared library or in a threaded
54 ******************************************************************************/
56 struct aroscbase
*aroscbase
= __aros_getbase();
59 /* Allocate the memory */
60 mem
= AllocPooled (aroscbase
->acb_mempool
, size
+ AROS_ALIGN(sizeof(size_t)));
63 *((size_t *)mem
) = size
;
64 mem
+= AROS_ALIGN(sizeof(size_t));
74 int __init_memstuff(struct aroscbase
*aroscbase
)
76 D(bug("__init_memstuff: task(%x), aroscbase(%x)\n",
77 FindTask(NULL
), aroscbase
80 aroscbase
->acb_mempool
= CreatePool(MEMF_ANY
| MEMF_SEM_PROTECTED
, 65536L, 4096L);
82 D(bug("__init_memstuff: aroscbase->acb_mempool(%x)\n", aroscbase
->acb_mempool
));
84 if (!aroscbase
->acb_mempool
)
93 void __exit_memstuff(struct aroscbase
*aroscbase
)
95 D(bug("__exit_memstuff: task(%x), aroscbase(%x), acb_mempool(%x)\n",
96 FindTask(NULL
), aroscbase
, aroscbase
->acb_mempool
99 if (aroscbase
->acb_mempool
)
101 DeletePool(aroscbase
->acb_mempool
);
105 ADD2OPENLIB(__init_memstuff
, 0);
106 ADD2CLOSELIB(__exit_memstuff
, 0);