home *** CD-ROM | disk | FTP | other *** search
- /* Memory..start with runelf(SAS C)
- *
- * show how to use the pool system. Basicly it`s only a test if it works:-)
- *
- */
- #include <exec/memory.h>
- #include <powerup/gcclib/powerup_protos.h>
- #include <stdio.h>
- #include <string.h>
-
- #define POOLSIZE 0x20
- #define ALLOCSIZE 0x4
-
- void *AllocArray[(POOLSIZE/ALLOCSIZE)];
-
- int main(void)
- {
- void *MyPool;
- ULONG i;
- void *Mem;
-
- PPCprintf("Create a Pool with 0x%lx bytes per chunk\n",
- POOLSIZE);
-
- if (MyPool=PPCCreatePool(MEMF_PUBLIC,POOLSIZE,POOLSIZE))
- {
- for (i=0;i<(POOLSIZE/ALLOCSIZE);i++)
- {
- if (Mem=PPCAllocPooled(MyPool,ALLOCSIZE))
- {
- PPCprintf("Memory = 0x%lx\n",
- Mem);
- }
- else
- {
- PPCprintf("Pool allocation failed\n");
- }
- }
- PPCprintf("Delete Pool\n");
- PPCDeletePool(MyPool);
- }
- else
- {
- PPCprintf("Pool creation failed\n");
- }
- return(0);
- }
-
-