1 #include <exec/memory.h>
2 #include <exec/semaphores.h>
3 #include <proto/exec.h>
7 #define PoolSize 131072
8 static void *MemPool
= NULL
;
9 static struct SignalSemaphore PoolSem
;
11 ULONG
InitSupport(void)
13 if ((MemPool
= CreatePool(MEMF_PUBLIC
, PoolSize
, PoolSize
)))
15 InitSemaphore(&PoolSem
);
22 void RemoveSupport(void)
31 void *malloc(unsigned long size
)
35 if (size
== 0) return NULL
;
38 ObtainSemaphore(&PoolSem
);
39 MyMemory
= (ULONG
*)AllocPooled(MemPool
, size
);
40 ReleaseSemaphore(&PoolSem
);
46 if ((ULONG
)MyMemory
& 7)
52 return((void *)MyMemory
);
55 void *calloc(unsigned long nobj
, unsigned long size
)
57 unsigned long siz
= size
* nobj
;
60 if ((ptr
= malloc(siz
)))
71 if (ptr
== NULL
) return;
81 ObtainSemaphore(&PoolSem
);
82 FreePooled(MemPool
, MemPtr
, Size
);
83 ReleaseSemaphore(&PoolSem
);