home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 387b.lha / dice_v2.02 / lib / memory / free.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-30  |  504 b   |  37 lines

  1.  
  2. /*
  3.  *  FREE.C
  4.  *
  5.  *  (c)Copyright 1990, Matthew Dillon, All Rights Reserved
  6.  */
  7.  
  8. #include <exec/types.h>
  9. #include <exec/memory.h>
  10. #include <stdlib.h>
  11.  
  12. extern long *__MemList;
  13.  
  14. void
  15. free(ptr)
  16. void *ptr;
  17. {
  18.     long **scan = &__MemList;
  19.     long *item;
  20.  
  21.     if (ptr == NULL)
  22.     Wait(0);
  23.  
  24.     ptr = (void *)((long *)ptr - 2);
  25.  
  26.     while (item = *scan) {
  27.     if (item == (long *)ptr) {
  28.         *scan = *(long **)item;
  29.         FreeMem(ptr, ((long *)ptr)[1]);
  30.         return;
  31.     }
  32.     scan = (long **)item;
  33.     }
  34.     Wait(0);
  35. }
  36.  
  37.