CFx SDK Documentation
2024 SP0
Loading...
Searching...
No Matches
SDK
CFx
dd_inc
OdHeap.h
Go to the documentation of this file.
1
2
// Copyright (C) 2002-2022, Open Design Alliance (the "Alliance").
3
// All rights reserved.
4
//
5
// This software and its documentation and related materials are owned by
6
// the Alliance. The software may only be incorporated into application
7
// programs owned by members of the Alliance, subject to a signed
8
// Membership Agreement and Supplemental Software License Agreement with the
9
// Alliance. The structure and organization of this software are the valuable
10
// trade secrets of the Alliance and its suppliers. The software is also
11
// protected by copyright law and international treaty provisions. Application
12
// programs incorporating this software must include the following statement
13
// with their copyright notices:
14
//
15
// This application incorporates Open Design Alliance software pursuant to a license
16
// agreement with Open Design Alliance.
17
// Open Design Alliance Copyright (C) 2002-2022 by Open Design Alliance.
18
// All rights reserved.
19
//
20
// By use of this software, its documentation or related materials, you
21
// acknowledge and accept the above terms.
23
24
25
#ifndef _OD_HEAPOPERATORS_INCLUDED_
26
#define _OD_HEAPOPERATORS_INCLUDED_
27
28
#include "
OdAlloc.h
"
29
#include <new>
30
31
#ifdef __BCPLUSPLUS__
// borland compiler does not support "placement delete"
32
36
#define ODRX_HEAP_OPERATORS() \
37
void* operator new(size_t s) { return ::odrxAlloc(s); }\
38
void operator delete(void* p) { ::odrxFree(p); }\
39
void* operator new[](size_t s) { return ::odrxAlloc(s); }\
40
void operator delete[](void* p) { ::odrxFree(p); }\
41
void *operator new(size_t, void* p) { return p; }\
42
void *operator new[](size_t, void* p) { return p; }
43
44
#elif defined(_MSC_VER) || (defined(__cplusplus) && (__cplusplus > 199711L))
45
// MSVC ignores exception specs (and gives warning)
46
// Dynamic exception specifications are deprecated in C++11
47
51
#define ODRX_HEAP_OPERATORS() \
52
void* operator new(size_t s)\
53
{\
54
void* p = ::odrxAlloc(s);\
55
if ( !p ) NEW_HANDLER()\
56
return p;\
57
}\
58
void operator delete(void* p) { ::odrxFree(p); }\
59
void* operator new[](size_t s)\
60
{\
61
void* p = ::odrxAlloc(s);\
62
if ( !p ) NEW_HANDLER()\
63
return p;\
64
}\
65
void operator delete[](void* p) { ::odrxFree(p); }\
66
void *operator new(size_t, void* p) { return p; }\
67
void operator delete( void*, void* ) {}\
68
void *operator new[](size_t, void* p) { return p; }\
69
void operator delete[]( void*, void* ) {}
70
71
#else
72
76
#define ODRX_HEAP_OPERATORS() \
77
void* operator new(size_t s) \
78
{\
79
void* p = ::odrxAlloc(s);\
80
if ( !p ) NEW_HANDLER()\
81
return p;\
82
}\
83
void operator delete(void* p) { ::odrxFree(p); }\
84
void* operator new[](size_t s) \
85
{\
86
void* p = ::odrxAlloc(s);\
87
if ( !p ) NEW_HANDLER()\
88
return p;\
89
}\
90
void operator delete[](void* p) { ::odrxFree(p); }\
91
void *operator new(size_t, void* p) throw() { return p; }\
92
void operator delete( void*, void* ) {}\
93
void *operator new[](size_t, void* p) throw() { return p; }\
94
void operator delete[]( void*, void* ) {}
95
96
#endif
97
98
#if !defined(_MSC_VER) || (_MSC_VER < 1900)
99
103
#define ODRX_NO_HEAP_OPERATORS() \
104
void* operator new(size_t ) throw() { ODA_FAIL(); return 0; }\
105
void operator delete(void* ) { ODA_FAIL(); throw OdError(eNotApplicable); }\
106
void* operator new[](size_t ) throw() { ODA_FAIL(); return 0; }\
107
void operator delete[](void* ) { ODA_FAIL(); throw OdError(eNotApplicable); }
108
109
#else
// defined(_MSC_VER) && (_MSC_VER >= 1900)
110
115
#define ODRX_NO_HEAP_OPERATORS() \
116
static void _throwOdError_eNotApplicable() { ODA_FAIL(); throw OdError(eNotApplicable); }\
117
void* operator new(size_t ) throw() { ODA_FAIL(); return 0; }\
118
void operator delete(void* ) { _throwOdError_eNotApplicable(); }\
119
void* operator new[](size_t ) throw() { ODA_FAIL(); return 0; }\
120
void operator delete[](void* ) { _throwOdError_eNotApplicable(); }
121
122
#endif
// defined(_MSC_VER) && (_MSC_VER >= 1900)
123
124
#ifdef OD_REDEFINE_HEAP_OPERATORS
125
129
#define ODRX_USING_HEAP_OPERATORS(T) \
130
void* operator new(size_t s) throw() { return T::operator new(s); }\
131
void operator delete(void* p) { T::operator delete(p); }\
132
void* operator new[](size_t s) throw() { return T::operator new(s); }\
133
void operator delete[](void* p) { T::operator delete(p); }
134
135
#else
136
140
#define ODRX_USING_HEAP_OPERATORS(T) \
141
using T::operator new;\
142
using T::operator delete;\
143
using T::operator new[];\
144
using T::operator delete[]
145
146
#endif
147
148
149
#endif
// _OD_HEAPOPERATORS_INCLUDED_
OdAlloc.h
Generated on Wed Apr 5 2023 17:29:21