2 Copyright © 1995-2009, The AROS Development Team. All rights reserved.
5 ANSI C function malloc().
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 /*****************************************************************************
22 #include <sys/types.h>
31 Allocate size bytes of memory and return the address of the
35 size - How much memory to allocate.
38 A pointer to the allocated memory or NULL. If you don't need the
39 memory anymore, you can pass this pointer to free(). If you don't,
40 the memory will be freed for you when the application exits.
43 This function must not be used in a shared library or in a threaded
55 ******************************************************************************/
59 /* Allocate the memory */
60 mem
= AllocPooled (__mempool
, size
+ AROS_ALIGN(sizeof(size_t)));
63 *((size_t *)mem
) = size
;
64 mem
+= AROS_ALIGN(sizeof(size_t));
74 int __init_memstuff(void)
76 D(bug("__init_memstuff: task(%x), privdata(%x)\n",
77 FindTask(NULL
), __get_arosc_privdata()
80 __mempool
= CreatePool(MEMF_ANY
| MEMF_SEM_PROTECTED
, 65536L, 4096L);
82 D(bug("__init_memstuff: __mempool(%x)\n", __mempool
));
93 void __exit_memstuff(void)
95 D(bug("__exit_memstuff: task(%x), privdata(%x), __mempool(%x)\n",
96 FindTask(NULL
), __get_arosc_privdata(), __mempool
101 DeletePool(__mempool
);
105 ADD2INIT(__init_memstuff
, 0);
106 ADD2EXIT(__exit_memstuff
, 0);