home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / aros / source / exec / memory / src / deletepool.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-16  |  1.6 KB  |  78 lines

  1. /*
  2.     (C) 1995 AROS - The Amiga Replacement OS
  3.     $Id: deletepool.c 1.1 1995/11/14 22:31:07 digulla Exp digulla $
  4.     $Log: deletepool.c $
  5.  * Revision 1.1  1995/11/14  22:31:07  digulla
  6.  * Initial revision
  7.  *
  8.     Desc:
  9.     Lang: english
  10. */
  11. #include "exec_intern.h"
  12. #include "memory.h"
  13.  
  14. /*****************************************************************************
  15.  
  16.     NAME */
  17.     #include <exec/memory.h>
  18.     #include <clib/exec_protos.h>
  19.  
  20.     __AROS_LH1(void, DeletePool,
  21.  
  22. /*  SYNOPSIS */
  23.     __AROS_LA(APTR, poolHeader, A0),
  24.  
  25. /*  LOCATION */
  26.     struct ExecBase *, SysBase, 117, Exec)
  27.  
  28. /*  FUNCTION
  29.     Delete a pool including all it's memory.
  30.  
  31.     INPUTS
  32.     poolHeader - The pool allocated with CreatePool() or NULL.
  33.  
  34.     RESULT
  35.  
  36.     NOTES
  37.  
  38.     EXAMPLE
  39.  
  40.     BUGS
  41.  
  42.     SEE ALSO
  43.     CreatePool(), AllocPooled(), FreePooled()
  44.  
  45.     INTERNALS
  46.  
  47.     HISTORY
  48.     16-10-95    created by m. fleischer
  49.     26-10-95    digulla adjusted to new calling scheme
  50.  
  51. ******************************************************************************/
  52. {
  53.     __AROS_FUNC_INIT
  54.     struct Pool *pool=(struct Pool *)poolHeader;
  55.  
  56.     /* It is legal to DeletePool(NULL) */
  57.     if(pool!=NULL)
  58.     {
  59.     void *p;
  60.     struct Block *bl;
  61.     ULONG size;
  62.  
  63.     /* Calculate the total size of a puddle including header. */
  64.     size=pool->PuddleSize+MEMHEADER_TOTAL;
  65.     /* Free the list of puddles */
  66.     while((p=RemHead((struct List *)&pool->PuddleList))!=NULL)
  67.         FreeMem(p,size);
  68.  
  69.     /* Free the list of single Blocks */
  70.     while((bl=(struct Block *)RemHead((struct List *)&pool->BlockList))!=NULL)
  71.         FreeMem(bl,bl->Size);
  72.  
  73.     FreeMem(pool,sizeof(struct Pool));
  74.     }
  75.     __AROS_FUNC_EXIT
  76. } /* DeletePool */
  77.  
  78.