2003-11-27 00:21:04 +00:00
|
|
|
/* $Id: u_mem.h,v 1.7 2003-11-27 00:21:04 btb Exp $ */
|
2001-01-19 03:30:16 +00:00
|
|
|
/*
|
|
|
|
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
|
|
|
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
|
|
|
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
|
|
|
|
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
|
|
|
|
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
|
|
|
|
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
|
|
|
|
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
|
|
|
|
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
|
2003-11-27 00:21:04 +00:00
|
|
|
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
|
2001-01-19 03:30:16 +00:00
|
|
|
COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|
|
|
*/
|
2003-11-27 00:21:04 +00:00
|
|
|
|
2001-01-22 13:37:46 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2001-01-19 03:30:16 +00:00
|
|
|
#ifdef MACINTOSH
|
|
|
|
extern ubyte virtual_memory_on;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(NDEBUG) || defined(MACINTOSH) // mac always gets this stuff.
|
|
|
|
|
|
|
|
extern int show_mem_info;
|
|
|
|
|
2001-11-08 10:17:40 +00:00
|
|
|
void mem_display_blocks();
|
2001-01-19 03:30:16 +00:00
|
|
|
extern void * mem_malloc( unsigned int size, char * var, char * file, int line, int fill_zero );
|
2001-11-08 10:17:40 +00:00
|
|
|
extern void * mem_realloc( void * buffer, unsigned int size, char * var, char * file, int line );
|
2001-01-19 03:30:16 +00:00
|
|
|
extern void mem_free( void * buffer );
|
2002-07-23 00:52:46 +00:00
|
|
|
extern char * mem_strdup(char * str, char * var, char * file, int line );
|
2001-01-19 03:30:16 +00:00
|
|
|
|
|
|
|
/* DPH: Changed malloc, etc. to d_malloc. Overloading system calls is very evil and error prone */
|
2002-07-23 00:52:46 +00:00
|
|
|
#define d_malloc(size) mem_malloc((size),"Unknown", __FILE__,__LINE__, 0 )
|
|
|
|
#define d_calloc(n,size) mem_malloc((n*size),"Unknown", __FILE__,__LINE__, 1 )
|
2001-11-08 10:17:40 +00:00
|
|
|
#define d_realloc(ptr,size) mem_realloc((ptr),(size),"Unknown", __FILE__,__LINE__ )
|
2002-07-23 00:52:46 +00:00
|
|
|
#define d_free(ptr) do{ mem_free(ptr); ptr=NULL; } while(0)
|
|
|
|
#define d_strdup(str) mem_strdup((str),"Unknown",__FILE__,__LINE__)
|
2001-01-19 03:30:16 +00:00
|
|
|
|
|
|
|
#define MALLOC( var, type, count ) (var=(type *)mem_malloc((count)*sizeof(type),#var, __FILE__,__LINE__,0 ))
|
|
|
|
|
|
|
|
// Checks to see if any blocks are overwritten
|
|
|
|
void mem_validate_heap();
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2002-07-23 00:52:46 +00:00
|
|
|
#define d_malloc(size) malloc(size)
|
2003-06-18 08:00:31 +00:00
|
|
|
#define d_calloc(n, size) calloc(n, size)
|
2001-11-08 10:17:40 +00:00
|
|
|
#define d_realloc(ptr,size) realloc(ptr,size)
|
2002-07-23 00:52:46 +00:00
|
|
|
#define d_free(ptr) do{ free(ptr); ptr=NULL; } while(0)
|
|
|
|
#define d_strdup(str) strdup(str)
|
2001-01-19 03:30:16 +00:00
|
|
|
|
|
|
|
#define MALLOC( var, type, count ) (var=(type *)malloc((count)*sizeof(type)))
|
|
|
|
|
|
|
|
#endif
|