home *** CD-ROM | disk | FTP | other *** search
/ MACD 4 / MACD4.iso / Emulatory / AROS / exec / deletepool.c < prev    next >
Encoding:
C/C++ Source or Header  |  1978-03-06  |  1.9 KB  |  91 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: deletepool.c,v 1.6 1996/10/24 15:50:47 aros Exp $
  4.     $Log: deletepool.c,v $
  5.     Revision 1.6  1996/10/24 15:50:47  aros
  6.     Use the official AROS macros over the __AROS versions.
  7.  
  8.     Revision 1.5  1996/10/19 17:07:25  aros
  9.     Include <aros/machine.h> instead of machine.h
  10.  
  11.     Revision 1.4  1996/08/13 13:56:00  digulla
  12.     Replaced AROS_LA by AROS_LHA
  13.     Replaced some AROS_LH*I by AROS_LH*
  14.     Sorted and added includes
  15.  
  16.     Revision 1.3  1996/08/01 17:41:09  digulla
  17.     Added standard header for all files
  18.  
  19.     Desc:
  20.     Lang:
  21. */
  22. #include "exec_intern.h"
  23. #include <aros/libcall.h>
  24. #include <aros/machine.h>
  25. #include "memory.h"
  26.  
  27. /*****************************************************************************
  28.  
  29.     NAME */
  30.     #include <exec/memory.h>
  31.     #include <clib/exec_protos.h>
  32.  
  33.     AROS_LH1(void, DeletePool,
  34.  
  35. /*  SYNOPSIS */
  36.     AROS_LHA(APTR, poolHeader, A0),
  37.  
  38. /*  LOCATION */
  39.     struct ExecBase *, SysBase, 117, Exec)
  40.  
  41. /*  FUNCTION
  42.     Delete a pool including all it's memory.
  43.  
  44.     INPUTS
  45.     poolHeader - The pool allocated with CreatePool() or NULL.
  46.  
  47.     RESULT
  48.  
  49.     NOTES
  50.  
  51.     EXAMPLE
  52.  
  53.     BUGS
  54.  
  55.     SEE ALSO
  56.     CreatePool(), AllocPooled(), FreePooled()
  57.  
  58.     INTERNALS
  59.  
  60.     HISTORY
  61.     16-10-95    created by m. fleischer
  62.  
  63. ******************************************************************************/
  64. {
  65.     AROS_LIBFUNC_INIT
  66.  
  67.     struct Pool *pool=(struct Pool *)poolHeader;
  68.  
  69.     /* It is legal to DeletePool(NULL) */
  70.     if(pool!=NULL)
  71.     {
  72.     void *p;
  73.     struct Block *bl;
  74.     ULONG size;
  75.  
  76.     /* Calculate the total size of a puddle including header. */
  77.     size=pool->PuddleSize+MEMHEADER_TOTAL;
  78.     /* Free the list of puddles */
  79.     while((p=RemHead((struct List *)&pool->PuddleList))!=NULL)
  80.         FreeMem(p,size);
  81.  
  82.     /* Free the list of single Blocks */
  83.     while((bl=(struct Block *)RemHead((struct List *)&pool->BlockList))!=NULL)
  84.         FreeMem(bl,bl->Size);
  85.  
  86.     FreeMem(pool,sizeof(struct Pool));
  87.     }
  88.     AROS_LIBFUNC_EXIT
  89. } /* DeletePool */
  90.  
  91.