home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / compiler / clib / free.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-09  |  1014 b   |  62 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: free.c,v 1.5 1997/01/01 03:41:10 ldp Exp $
  4.  
  5.     Desc: ANSI C function free()
  6.     Lang: english
  7. */
  8. #include <exec/memory.h>
  9. #include <proto/exec.h>
  10. extern APTR __startup_mempool;
  11.  
  12. /*****************************************************************************
  13.  
  14.     NAME */
  15. #include <stdlib.h>
  16.  
  17.     void free (
  18.  
  19. /*  SYNOPSIS */
  20.     void * memory)
  21.  
  22. /*  FUNCTION
  23.     Return memory allocated with malloc() or a similar function to the
  24.     system.
  25.  
  26.     INPUTS
  27.     memory - The result of the previous call to malloc(), etc. or
  28.         NULL.
  29.  
  30.     RESULT
  31.     None.
  32.  
  33.     NOTES
  34.  
  35.     EXAMPLE
  36.  
  37.     BUGS
  38.  
  39.     SEE ALSO
  40.     malloc()
  41.  
  42.     INTERNALS
  43.  
  44.     HISTORY
  45.     24-12-95    digulla created
  46.  
  47. ******************************************************************************/
  48. {
  49.     UBYTE * mem;
  50.     size_t size;
  51.  
  52.     if (memory && __startup_mempool)
  53.     {
  54.     mem = ((UBYTE *)memory) - AROS_ALIGN(sizeof(size_t));
  55.     size = *((size_t *)mem);
  56.  
  57.     FreePooled (__startup_mempool, mem, size);
  58.     }
  59.  
  60. } /* free */
  61.  
  62.