home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Black Box 4
/
BlackBox.cdr
/
progc
/
dmldmo.arj
/
DMALLOC.H
< prev
next >
Wrap
C/C++ Source or Header
|
1992-04-12
|
5KB
|
152 lines
/***************************************************************************/
/* */
/* DMALLOC.H v.0.9 for MSC 5.1 and 6.+ */
/* */
/* (C) 1991-1992 E.Vogelsinger 03/30/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 !defined _DMALLOC
// if DMalloc is switched off, define anything so the compiler
// would not protest
#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()
#define DML_SAVEAREA(name)
#else
// let the programmer know that DMalloc is on
#pragma message ("DMalloc heap check enabled")
// redefine the malloc function calls to our entry points
#define malloc(size) DM_malloc$(size,__FILE__,__LINE__)
#define free(ptr) DM_free$(ptr,__FILE__,__LINE__)
#define calloc(cnt,size) DM_calloc$(cnt,size,__FILE__,__LINE__)
#define realloc(ptr,size) DM_realloc$(ptr,size,__FILE__,__LINE__)
#define _fmalloc(size) DM_malloc$(size,__FILE__,__LINE__)
#define _ffree(ptr) DM_free$(ptr,__FILE__,__LINE__)
#define _nmalloc(size) DM_nmalloc$(size,__FILE__,__LINE__)
#define _nfree(ptr) DM_nfree$(ptr,__FILE__,__LINE__)
// using DML_Trigger, we want to have information about the
// source as well
#define DML_Trigger() DM_Trigger$(__FILE__, __LINE__)
// define the buffer variable needed to save the DMalloc state
#define DML_SAVESIZE (128)
#define DML_SAVEAREA(name) 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 * DM_nmalloc$ (size_t size,
char * pszFile,
unsigned usLine);
void DM_nfree$ (void * pUnit,
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);
void pascal DML_Check (void);
#endif
#endif