www.pudn.com > EZW_.rar > MEMCHK.H


#ifndef __MEMCHK_H__ 
#define __MEMCHK_H__ 
/*----------------------------------------------------------------------------*/ 
/*----------------------------------------------------------------------------*/ 
/* Adapted/reformated to suit my own coding style. Some changes to the  
 * printing. Also the defintion that enable/disable the memory checker. 
 * Added a few functions and definitions. 
 * 
 * Mow-Song, Ng 2/9/2002 
 * msng@mmu.edu.my 
 * http://www.pesona.mmu.edu.my/~msng 
 * 
 * I do not claim copyright to the code, but if you use them or modify them, 
 * please drop me a mail. 
 * 
 */ 
/*----------------------------------------------------------------------------*/ 
/*----------------------------------------------------------------------------*/ 
 
/*----------------------------------------------------------------------------*/ 
/*----------------------------------------------------------------------------*/ 
/* Original code from LiftPack */ 
/* 
 *  -*- Mode: ANSI C -*- 
 *  $Id: memchk.h,v 1.4 1996/11/06 20:52:23 fernande Exp $ 
 *  $Header: /sgi.acct/sweldens/cvs/liftpack/include/memchk.h,v 1.4  
 *           1996/11/06 20:52:23 fernande Exp $ 
 *  Author: Sridhar, M. A. 
 *  Modified: Gabriel Fernandez 
 * 
 *  Contains declarations of memory management functions to control 
 *  memory leaks in a C source code. 
 */ 
/*----------------------------------------------------------------------------*/ 
/*----------------------------------------------------------------------------*/ 
 
#include  
 
//#define __MEMCHK_ENABLE_ 
 
/* allocate memory and initialize it with zeros */ 
extern void * 
Calloc (size_t __number, size_t __size, int __line_no, char* __file_name); 
 
/* allocate a new memory block for a given pointer */ 
extern void * 
Realloc (void* __ptr, size_t __size, int __line_no, char* __file_name); 
 
/* allocate memory and keep track of important information */ 
extern void * 
Malloc (size_t __size, int __line_no, char* __file_name); 
 
/* free memory and delete entry in Malloc list */ 
extern void 
Free (void* __p); 
 
 
/* print content of Malloc list of allocations */ 
extern int 
PrintLeaks (void); 
 
/* free memory pointed out by the Malloc list */ 
extern void 
FreeLeaks (void); 
 
/* return the maximum memory used */ 
extern long  
MaxMemory(void); 
 
/* return the current memory allocated */ 
extern long  
CurrentMemoryAllocated(void); 
 
#ifdef __MEMCHK_ENABLE_ 
/* definitions for all programs to use Realloc, Calloc, Malloc, and Free */ 
#define calloc(n, s)  Calloc(n, s, __LINE__, __FILE__) 
#define realloc(p, s) Realloc(p, s, __LINE__, __FILE__) 
#define malloc(s)     Malloc(s, __LINE__, __FILE__) 
#define free(s)       Free(s) 
#endif /* __MEMCHK_ENABLE_ */ 
 
#endif /* __MEMCHK_H__ */