/*
 * PoolTest 1.0 © D. Göhler (15.07.94)
 *
 * Übersetzen mit (für DICE oder SAS C):
 * sc LINK PoolTest.c PoolSupport.c AllocSupport.c
 * dcc PoolTest.c PoolSupport.c AllocSupport.c
 */

#include <clib/dos_protos.h>
#include <exec/memory.h>
#include <stdlib.h>
#include <stdio.h>

#define GROESSE  100000  // 'großes' Stück
#define THRES     80000  // ab 80000 neues Stück
#define ANZAHL        5  // Allozierungen pro Pool

void *CreatePool13(ULONG Flags,ULONG RegionSize, 
                   ULONG NewSize);
void DeletePool13(APTR MyPool);
APTR AllocPooled13(void *MyPool,ULONG Size);
void FreePooled13(void *MyPool, APTR memaddr);

APTR memblocks[ANZAHL];

int main(int argc, char *agrv[])
{
   APTR mypool;
   register int i = 0;

   if (mypool = CreatePool13(MEMF_PUBLIC,GROESSE,
                             THRES))
   {
      memblocks[0] = AllocPooled13(mypool,20);
      memblocks[1] = AllocPooled13(mypool,20000);
                         // das geht auch !!
      memblocks[2] = AllocPooled13(mypool,120000); 
                         // das ergibt letztlich 20
      memblocks[3] = AllocPooled13(mypool,19); 
                         // das ergibt letztlich 8
      memblocks[4] = AllocPooled13(mypool,1);  

      /* diese 2 Zeilen sind unnütz, nur zur Demo */
      for (i=0; memblocks[i]; i++)
      {  printf("i hat den Wert %ld\n",i);
         FreePooled13(mypool, memblocks[i]); }

      DeletePool13(mypool); // Pool freigeben
   }
   return 0L;
}

