home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / PowerPC / Dev / PPCRelease / Examples / Memory / Memory.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-07  |  902 b   |  49 lines

  1. /* Memory..start with runelf(SAS C)
  2.  * 
  3.  * show how to use the pool system. Basicly it`s only a test if it works:-)
  4.  *
  5.  */
  6. #include <exec/memory.h>
  7. #include <powerup/gcclib/powerup_protos.h>
  8. #include <stdio.h>
  9. #include <string.h>
  10.  
  11. #define    POOLSIZE    0x20
  12. #define    ALLOCSIZE    0x4
  13.  
  14. void    *AllocArray[(POOLSIZE/ALLOCSIZE)];
  15.  
  16. int    main(void)
  17. {
  18. void    *MyPool;
  19. ULONG    i;
  20. void    *Mem;
  21.  
  22.   PPCprintf("Create a Pool with 0x%lx bytes per chunk\n",
  23.             POOLSIZE);
  24.  
  25.   if (MyPool=PPCCreatePool(MEMF_PUBLIC,POOLSIZE,POOLSIZE))
  26.   {
  27.     for (i=0;i<(POOLSIZE/ALLOCSIZE);i++)
  28.     {
  29.       if (Mem=PPCAllocPooled(MyPool,ALLOCSIZE))
  30.       {
  31.         PPCprintf("Memory = 0x%lx\n",
  32.                   Mem);
  33.       }
  34.       else
  35.       {
  36.         PPCprintf("Pool allocation failed\n");
  37.       }
  38.     }
  39.     PPCprintf("Delete Pool\n");
  40.     PPCDeletePool(MyPool);
  41.   }
  42.   else
  43.   {
  44.     PPCprintf("Pool creation failed\n");
  45.   }
  46.   return(0);
  47. }
  48.  
  49.