home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1996 November
/
VPR9611B.ISO
/
vabasic
/
ntclnt.exe
/
DISK8
/
data.8
/
datab
/
INCLUDE
/
DLLCLASS.HH
< prev
next >
Wrap
Text File
|
1996-07-29
|
4KB
|
182 lines
/*****************************************************************************
*** $Source: /rcs/crcs/general/dllclass.hh,v $
*** Checked int by: $Author: patrice $
*** $Date: 1995/11/27 01:28:16 $
*** $Revision: 1.8 $
*****************************************************************************
*** ***
*** Copyright (c) 1994, Visual Edge Software Ltd. ***
*** ***
*** All rights reserved. This notice is intended as a precaution ***
*** against inadvertent publication, and shall not be deemed to con- ***
*** stitute an acknowledgment that publication has occurred nor to ***
*** imply any waiver of confidentiality. The year included in the ***
*** notice is the year of the creation of the work. ***
*** ***
*****************************************************************************/
// Copyright (c) International Business Machines Inc, 1995
#ifndef DLLCLASS_HH
#define DLLCLASS_HH
#include <stdlib.h>
#include <vealloc.h>
#ifdef new
// We are in debugging malloc mode: undefine the new operator for now.
#undef new
#undef OP_NEW
#endif
//-----------------------------------------------------------------------------
// Class VeDllBasedClass
// Base class for all objects which are to be located in DLL's
// Provides new and delete operator for the class.
// These operators make sure the memory is allocated in the correct
// location. This also provides support for the debugging VeMalloc.
// LAST REV: January 31, 1995 Fix8122
//-----------------------------------------------------------------------------
class VeDllBasedClass
{
public:
// Due to bugs in the HP C++ compiler inline operators
// must be defined inside the class definition.
#if defined(MEMDEBUG) && !defined(NOVIPERNEW)
void* operator new(size_t size, const char *fname, unsigned lnum)
{
return VeDebugMalloc(size, fname, lnum);
}
#ifdef ANSIcplusplus
void* operator new[](size_t size, const char *fname, unsigned lnum)
{
return VeDebugMalloc(size, fname, lnum);
}
#endif // ANSIcplusplus
#endif // defined(MEMDEBUG) && !defined(NOVIPERNEW)
#ifdef __DEBUG_ALLOC__
void* operator new(size_t size, const char *, size_t)
#else
void* operator new(size_t size)
#endif
{
return VeMalloc(size);
}
#ifdef ANSIcplusplus
void* operator new[](size_t size)
{
return VeMalloc(size);
}
#endif // ANSIcplusplus
#ifdef __DEBUG_ALLOC__
void operator delete(void *pntr, const char *, size_t)
#else
void operator delete(void *pntr)
#endif
{
VeFree(pntr);
}
};
//=============================================================================
#if defined(MEMDEBUG) && !defined(NOVIPERNEW)
#define VNEW_LOC(b) \
void* operator new(size_t size, const char *fname, unsigned lnum) \
{ \
return b::operator new (size, fname, lnum); \
}
#ifdef ANSIcplusplus
#define VNEWARRAY_LOC(b) \
void* operator new[](size_t size, const char *fname, unsigned lnum) \
{ \
return b::operator new (size, fname, lnum); \
}
#else // ANSIcplusplus
#define VNEWARRAY_LOC(b)
#endif // ANSIcplusplus
#else // MEMDEBUG && !NOVIPERNEW
#define VNEW_LOC(b)
#define VNEWARRAY_LOC(b)
#endif // MEMDEBUG && !NOVIPERNEW
#ifdef __DEBUG_ALLOC__
#define VNEW(b) \
void *operator new (size_t size, const char *fname, size_t line) \
{ \
return b::operator new (size, fname, line); \
}
#else
#define VNEW(b) \
void *operator new (size_t size) \
{ \
return b::operator new (size); \
}
#endif
#ifdef ANSIcplusplus
#ifdef __DEBUG_ALLOC__
#define VNEWARRAY(b) \
void *operator new[](size_t size, const char *fname, size_t line) \
{ \
return b::operator new (size, fname, line); \
}
#else
#define VNEWARRAY(b) \
void *operator new[](size_t size) \
{ \
return b::operator new (size); \
}
#endif
#else // ANSIcplusplus
#define VNEWARRAY(b)
#endif // ANSIcplusplus
#ifdef __DEBUG_ALLOC__
#define VDELETE(b) \
void operator delete (void *ptr, const char *fname, size_t line) \
{ \
b::operator delete (ptr, fname, line); \
}
#else
#define VDELETE(b) \
void operator delete (void *ptr) \
{ \
b::operator delete (ptr); \
}
#endif
#define VMI_ALLOCATION(b) VNEW(b) \
VNEWARRAY(b) \
VDELETE(b)
// Redefine the new operator now that we are done.
#include <defnew.hh>
#endif // DLLCLASS_HH