home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Shareware - Software Farm 2
/
wosw_2.zip
/
wosw_2
/
CPROG
/
DMALLOC.ZIP
/
INSTALL.LIB
/
DMALLOC.H
< prev
next >
Wrap
C/C++ Source or Header
|
1992-11-01
|
7KB
|
202 lines
/***************************************************************************/
/* */
/* DMALLOC.H v1.0 for MSC */
/* */
/* (C) 1991-1992 E.Vogelsinger 09/01/92 */
/***************************************************************************/
#if !defined(_DMALLOC_INCLUDED)
#define _DMALLOC_INCLUDED
/* ==== a) Definitions =================================================== */
/* Valid values for DML_Setup and DML_Select */
#define SET_OFF 0
#define SET_ON 1
#define SET_SAVED 1
#define SET_CORRUPTED 2
#define SET_BOTH 3
#define SET_UNCHANGED -1
#define PSZ_UNCHANGED ((void *)-1)
/* Valid values for DML_Breakpoint */
#define BPT_SOFTICE 1
#define BPT_CODEVIEW 2
#define BPT_INT3 3
/* Values for Watchpoint */
#define FAR_NULLCHECK ((void *)0)
#define DATA_NULLCHECK ((void *)1)
/* ==== b) Macros ======================================================== */
/*
* check if we are really compiling large model
*/
#if defined _DMALLOC
# if !defined M_I86LM && !defined M_I86CM
# undef _DMALLOC
# pragma message ("DMalloc v.1.0 needs the LARGE memory model!")
# error *** Abort ***
# endif
#endif
/*
* if DMalloc is switched off, define anything
* so the compiler would not protest
*/
#if !defined _DMALLOC
# define DML_Trigger()
# define DML_Setup(f1,f2,f3)
# define DML_Select(f1,f2,f3,f4,f5,p,l)
# define DML_SaveState(p)
# define DML_RestoreState(p)
# define DML_Watchpoint(p,f) (1) /* returns nonzero if ptr is valid */
# define DML_Savepoint(p,f) (1) /* here we must assume it is! */
# define DML_Breakpoint(f)
# define DML_Disable()
# define DML_Enable()
# define DML_Check() (0) /* return no failure - heap is ok */
# define DML_CheckPop()
# define DML_SAVEAREA(name)
#else
/*
* _DMALLOC is defined
*
* say that DMalloc is active
*/
# pragma message ("DMalloc heap check enabled")
/*
* There is one problem with the __FILE__ macro:
*
* Each time __FILE__ is used, the complete pathname
* of the source file will be included within DGROUP!
*
* Solution:
* Before including DMALLOC.H, insert the following lines:
* char * DM_file$ = __FILE__;
* #define __DMFILE__
*
* Then include DMALLOC.H
*
* You cannot use the __FILE__ macro within DMALLOC.H,
* since it will resolve to the name of the include file!
*
*/
#if !defined __DMFILE__
# pragma message ("DML: Warning - __DMFILE__ undefined!")
# pragma message (" Multiple strings will be added to DGROUP!")
# pragma message (" Read explanation in DMALLOC.H or your manual.")
# define DM_file$ __FILE__
#endif
/*
* redefine the malloc function calls to our entry points
*/
#define malloc(size) DM_malloc$(size,DM_file$,__LINE__)
#define free(ptr) DM_free$(ptr,DM_file$,__LINE__)
#define calloc(cnt,size) DM_calloc$(cnt,size,DM_file$,__LINE__)
#define realloc(ptr,size) DM_realloc$(ptr,size,DM_file$,__LINE__)
#define _fmalloc(size) DM_malloc$(size,DM_file$,__LINE__)
#define _ffree(ptr) DM_free$(ptr,DM_file$,__LINE__)
#define _nmalloc(size) DM_nmalloc$(size,DM_file$,__LINE__)
#define _nfree(ptr) DM_nfree$(ptr,DM_file$,__LINE__)
#define _expand(ptr,size) DM_expand$(ptr,size,DM_file$,__LINE__)
/*
* using DML_Trigger, we want to have information about the
* source as well
*/
#define DML_Trigger() DM_Trigger$(DM_file$, __LINE__)
/*
* combine check and popup
*/
#define DML_CheckPop() if(DML_Check()) DML_Trigger();
/*
* define the buffer variable needed to save the DMalloc state
*/
#define DML_SAVESIZE (128)
#define DML_SAVEAREA(name) unsigned char name[DML_SAVESIZE]
/* ==== c) Typedefs ====================================================== */
#if !defined _SIZE_T_DEFINED
typedef unsigned int size_t;
# define _SIZE_T_DEFINED
#endif
/* ==== d) Prototypes ==================================================== */
void * DM_malloc$ (size_t size,
char * pszFile,
unsigned usLine);
void DM_free$ (void * pUnit,
char * pszFile,
unsigned usLine);
void * DM_calloc$ (size_t size,
size_t count,
char * pszFile,
unsigned usLine);
void * DM_realloc$ (void * pUnit,
size_t size,
char * pszFile,
unsigned usLine);
void near * DM_nmalloc$ (size_t size,
char * pszFile,
unsigned usLine);
void DM_nfree$ (void near * pUnit,
char * pszFile,
unsigned usLine);
void * DM_expand$ (void * pUnit,
size_t size,
char * pszFile,
unsigned usLine);
void pascal DM_Trigger$ (char * pszFile,
unsigned usLine);
void pascal DML_Setup (unsigned fAlert,
unsigned fSaved,
unsigned usPopCycles,
unsigned usCheckCycles,
char * pszOwner,
unsigned usLine);
void pascal DML_Select (unsigned fMalloc,
unsigned fMarked,
unsigned fNull,
unsigned fData,
unsigned fSystem,
char *pszOwner,
unsigned usLine);
void pascal DML_SaveState (void * pSave);
void pascal DML_RestoreState(void * pSave);
unsigned pascal DML_Watchpoint (void far *p,
unsigned fOnOff);
unsigned pascal DML_Savepoint (void far *p,
unsigned fOnOff);
void pascal DML_Breakpoint (unsigned fType);
void pascal DML_Disable (void);
void pascal DML_Enable (void);
unsigned pascal DML_Check (void);
/* _DMALLOC defined */
#endif
/* _DMALLOC_INCLUDED undefined */
#endif