2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
8 #include "__stdc_intbase.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.
52 ******************************************************************************/
54 struct StdCIntBase
*StdCBase
= (struct StdCIntBase
*)__aros_getbase_StdCBase();
57 /* Allocate the memory */
58 mem
= AllocPooled (StdCBase
->mempool
, size
+ AROS_ALIGN(sizeof(size_t)));
61 *((size_t *)mem
) = size
;
62 mem
+= AROS_ALIGN(sizeof(size_t));
72 int __init_memstuff(struct StdCIntBase
*StdCBase
)
74 D(bug("__init_memstuff: task(%x), StdCBase(%x)\n",
75 FindTask(NULL
), StdCBase
78 StdCBase
->mempool
= CreatePool(MEMF_ANY
| MEMF_SEM_PROTECTED
, 65536L, 4096L);
80 D(bug("__init_memstuff: StdCBase->mempool(%x)\n", StdCBase
->mempool
));
82 if (!StdCBase
->mempool
)
91 void __exit_memstuff(struct StdCIntBase
*StdCBase
)
93 D(bug("__exit_memstuff: task(%x), StdCBase(%x), acb_mempool(%x)\n",
94 FindTask(NULL
), StdCBase
, StdCBase
->mempool
97 if (StdCBase
->mempool
)
99 DeletePool(StdCBase
->mempool
);
103 ADD2OPENLIB(__init_memstuff
, 0);
104 ADD2CLOSELIB(__exit_memstuff
, 0);