MEM.H 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
  12. */
  13. /*
  14. * $Source: f:/miner/source/mem/rcs/mem.h $
  15. * $Revision: 1.6 $
  16. * $Author: matt $
  17. * $Date: 1995/02/12 18:40:50 $
  18. *
  19. * Headers for safe malloc stuff.
  20. *
  21. * $Log: mem.h $
  22. * Revision 1.6 1995/02/12 18:40:50 matt
  23. * Made free() work the way it used to when debugging is on
  24. *
  25. * Revision 1.5 1995/02/12 04:07:36 matt
  26. * Made free() set ptrs to NULL even when no debugging
  27. *
  28. * Revision 1.4 1994/11/27 21:10:58 matt
  29. * Now supports NDEBUG to turn off all special mem checking
  30. *
  31. * Revision 1.3 1994/03/15 11:12:40 john
  32. * Made calloc fill block with zeros like it's
  33. * supposed to.
  34. *
  35. * Revision 1.2 1993/11/04 14:02:39 matt
  36. * Added calloc() macro
  37. *
  38. * Revision 1.1 1993/11/02 17:45:33 john
  39. * Initial revision
  40. *
  41. *
  42. */
  43. extern int show_mem_info;//moved out of the ifdef by KRB
  44. #ifndef NDEBUG
  45. //extern int show_mem_info;
  46. void * mem_display_blocks();
  47. extern void * mem_malloc( unsigned int size, char * var, char * file, int line, int fill_zero );
  48. extern void mem_free( void * buffer );
  49. #define malloc(size) mem_malloc((size),"Unknown", __FILE__,__LINE__, 0 )
  50. #define calloc(n,size) mem_malloc((n*size),"Unknown", __FILE__,__LINE__, 1 )
  51. #define free(ptr) do{ mem_free(ptr); ptr=NULL; } while(0)
  52. #define MALLOC( var, type, count ) (var=(type *)mem_malloc((count)*sizeof(type),#var, __FILE__,__LINE__,0 ))
  53. // Checks to see if any blocks are overwritten
  54. void mem_validate_heap();
  55. #else
  56. #define free(ptr) do{ free(ptr); ptr=NULL; } while(0)
  57. #define MALLOC( var, type, count ) (var=(type *)malloc((count)*sizeof(type)))
  58. #endif