home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1996 November
/
VPR9611B.ISO
/
vabasic
/
ntclnt.exe
/
DISK8
/
data.8
/
datab
/
INCLUDE
/
VEALLOC.H
< prev
next >
Wrap
C/C++ Source or Header
|
1996-07-29
|
5KB
|
149 lines
/*------------------------------------------------------------------------
* $Source: /rcs/crcs/general/vealloc.h,v $
* Checked in by: $Author: jose $
* $Date: 1996/04/23 12:52:40 $ $Revision: 1.3 $
*
* Copyright 1987, Techtrol Ltd.
* Copyright 1990, Visual Edge Software Ltd.
* -----------------------------------------
* ALL RIGHTS RESERVED. This notice is intended as a precaution against
* inadvertent publication, and shall not be deemed to constitute 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.
*------------------------------------------------------------------------*/
/*------------------------------------------------------------------------
*
* Module Name: valloc.h
* Module Description: Declarations for general allocation routines.
*
* Date: Unknown
*
*------------------------------------------------------------------------*/
#ifndef _VEALLOC_INCLUDED
#define _VEALLOC_INCLUDED
#include <stdio.h>
#include <os.h>
#include <visedge.h>
#ifdef __cplusplus
#define VECONST const
extern "C" {
#else
#define VECONST
#endif
extern VFUNCDECL(void*) VeMalloc UXPROTO((size_t));
extern VFUNCDECL(void*) VeCalloc UXPROTO((size_t, size_t));
extern VFUNCDECL(void*) VeRealloc UXPROTO((void *, size_t));
extern VFUNCDECL(void ) VeFree UXPROTO((void *));
extern VFUNCDECL(char*) VeCopyString UXPROTO(( char * ));
/* Definition of option parameters for VeMemAlloc, VeMemCalloc and VeMemRealloc.
These values specify how a memory crash is handled.
VRETURN_NOMEMORY: Tells the memory manager to return a NULL pointer to
the caller if memory crash occurs (this option has
precedence over VHANDLE_NOMEMORY).
VHANDLE_NOMEMORY: Memory crash is handled by the memory manager, no
pointer is returned to caller. The manager display an
error message and aborts the application.
VVERBOSE: Tells the memory manager to display an error message
if a memory crash occurs.
*/
#define VHANDLE_NOMEMORY (1<<0)
#define VRETURN_NOMEMORY (1<<1)
#define VVERBOSE (1<<2)
extern VFUNCDECL(void*) VeMemAlloc UXPROTO((size_t, int));
extern VFUNCDECL(void*) VeMemCalloc UXPROTO((size_t, size_t, int));
extern VFUNCDECL(void*) VeMemRealloc UXPROTO((void *, size_t, int));
#ifdef VSYS_WINDOWS
#include <malloc.h>
#define UxStackAlloc(size) _alloca((size) ? (size) : 4)
#define UxStackFree(pntr)
#else /* VSYS_WINDOWS */
#define UxStackAlloc(size) VeMalloc(size)
#define UxStackFree(pntr) VeFree(pntr)
#endif /* VSYS_WINDOWS */
#ifndef VSYS_NO_CLEANUP
VFUNCDECL(void) VeFreeAllMemory();
#endif
#if defined(MEMDEBUG) || defined(DEBUG)
typedef enum
{
MemoryAlwaysCheck = 0,
MemoryPrintZero = 1,
MemoryCrash = 2,
MemoryFill = 3,
MemoryFree = 4
} MemoryOption;
extern VFUNCDECL(void*) VeDebugMalloc UXPROTO((size_t, VECONST char *, unsigned));
extern VFUNCDECL(void*) VeDebugRealloc UXPROTO((void *, size_t, VECONST char *, unsigned));
extern VFUNCDECL(void*) VeDebugCalloc UXPROTO((size_t, size_t, VECONST char *, unsigned));
extern VFUNCDECL(void) VeDebugFree UXPROTO((void *, VECONST char *, unsigned));
extern VFUNCDECL(char*) VeDebugCopyString UXPROTO((char *, VECONST char *, unsigned));
extern VFUNCDECL(void*) VeCheckMemory UXPROTO(());
extern VFUNCDECL(void) VeShowMemory UXPROTO((FILE *fp));
extern VFUNCDECL(void) VeDumpMemory UXPROTO((VECONST char *fname));
extern VFUNCDECL(void) VeSetMemoryRunOut UXPROTO((unsigned long));
extern VFUNCDECL(void) VeSetMemoryOption UXPROTO((MemoryOption opt, int value));
#endif
#ifdef MEMDEBUG
#define VeMalloc(s) VeDebugMalloc(s, __FILE__, __LINE__)
#define VeRealloc(p, s) VeDebugRealloc(p, s, __FILE__, __LINE__)
#define VeCalloc(s, n) VeDebugCalloc(s, n, __FILE__, __LINE__)
#define VeFree(p) VeDebugFree(p, __FILE__, __LINE__)
#endif
/* Global function to change underlying memory allocation functions */
typedef void* VFUNCPTR(VTobAllocator)(size_t);
typedef void* VFUNCPTR(VTobReallocator)(void*, size_t);
typedef void VFUNCPTR(VTobDeallocator)(void*);
extern VFUNCDECL(status_t) VePutInternalAllocator UXPROTO((
VTobAllocator, VTobReallocator, VTobDeallocator));
#ifdef __cplusplus
}
#if defined(MEMDEBUG) && !defined(NOVIPERNEW)
VFUNCDECL(void*) operator new(size_t, const char *, unsigned);
#ifdef ANSIcplusplus
void *operator new[](size_t, const char *, unsigned);
#endif /* ANSIcplusplus */
#endif
/* Redefine the new operator for debugging support. */
#include <defnew.hh>
#endif
#define UxNew(t) (t *)VeCalloc(sizeof(t), 1)
#define UxNewArray(t, v) (t *)VeCalloc(sizeof(t), (v))
#endif /* _VEALLOC_INCLUDED */