/*
memory checking system derived from Dr Dobbs Journal
*/


/* #ifdef MEM_MALLOC */

#	define malloc(x)	Mem_malloc( (x), __FILE__, __LINE__ )
#	define calloc(x,y) 	Mem_calloc( (x), (y), __FILE__, __LINE__ )
#	define realloc(x,y) 	Mem_realloc( (x), (y), __FILE__, __LINE__ )
#	define strdup(x) 	Mem_strdup( (x), __FILE__, __LINE__ )
#	define xstrdup(x) 	Mem_xstrdup( (x), __FILE__, __LINE__ )
#	define xmalloc(x) 	Mem_xmalloc( (x), __FILE__, __LINE__ )
#	define xdatadup(x,y) 	Mem_xdatadup( (x), (y), __FILE__, __LINE__ )
#	define free(x)  	Mem_free( (x), __FILE__, __LINE__ )
#	define exit(n)		Mem_exit( n )

/* #endif */


extern int Mem_crash;	/* should we crash if malloc et al fail? */
			/* No if = 0; Yes, with Mem_crash = exit status */
			/* By default; Yes, exit status 1 */


extern void * Mem_malloc( size_t size, char * file, int line );
extern void * Mem_xmalloc( size_t size, char * file, int line );
extern void * Mem_xdatadup( size_t size, void * data, char * file, int line );
extern void * Mem_calloc( size_t n, size_t size, char * file, int line );
extern void * Mem_realloc( void * p, size_t size, char * file, int line );
extern char * Mem_strdup( char * p, char * file, int line );
extern char * Mem_xstrdup( char * p, char * file, int line );
extern void Mem_free( void * p, char * file, int line );
extern size_t Mem_used( void );
extern void Mem_show( FILE * f );
extern void Mem_check( void );
extern void Mem_exit( int n );
