CFx SDK Documentation
2026 SP0
Loading...
Searching...
No Matches
SDK
CFx
dd_inc
OdHeap.h
Go to the documentation of this file.
1
2
// Copyright (C) 2002-2024, 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-2024 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
#include <exception>
31
32
#ifdef __BCPLUSPLUS__
// borland compiler does not support "placement delete"
33
37
#define ODRX_HEAP_OPERATORS() \
38
void* operator new(size_t s) { return ::odrxAlloc(s); }\
39
void operator delete(void* p) { ::odrxFree(p); }\
40
void* operator new[](size_t s) { return ::odrxAlloc(s); }\
41
void operator delete[](void* p) { ::odrxFree(p); }\
42
void *operator new(size_t, void* p) { return p; }\
43
void *operator new[](size_t, void* p) { return p; }
44
45
#elif defined(_MSC_VER) || (defined(__cplusplus) && (__cplusplus > 199711L))
46
// MSVC ignores exception specs (and gives warning)
47
// Dynamic exception specifications are deprecated in C++11
48
52
#define ODRX_HEAP_OPERATORS() \
53
void* operator new(size_t s)\
54
{\
55
void* p = ::odrxAlloc(s);\
56
if ( !p ) NEW_HANDLER()\
57
return p;\
58
}\
59
void operator delete(void* p) { ::odrxFree(p); }\
60
void* operator new[](size_t s)\
61
{\
62
void* p = ::odrxAlloc(s);\
63
if ( !p ) NEW_HANDLER()\
64
return p;\
65
}\
66
void operator delete[](void* p) { ::odrxFree(p); }\
67
void *operator new(size_t, void* p) { return p; }\
68
void operator delete( void*, void* ) {}\
69
void *operator new[](size_t, void* p) { return p; }\
70
void operator delete[]( void*, void* ) {}
71
72
#else
73
77
#define ODRX_HEAP_OPERATORS() \
78
void* operator new(size_t s) \
79
{\
80
void* p = ::odrxAlloc(s);\
81
if ( !p ) NEW_HANDLER()\
82
return p;\
83
}\
84
void operator delete(void* p) { ::odrxFree(p); }\
85
void* operator new[](size_t s) \
86
{\
87
void* p = ::odrxAlloc(s);\
88
if ( !p ) NEW_HANDLER()\
89
return p;\
90
}\
91
void operator delete[](void* p) { ::odrxFree(p); }\
92
void *operator new(size_t, void* p) throw() { return p; }\
93
void operator delete( void*, void* ) {}\
94
void *operator new[](size_t, void* p) throw() { return p; }\
95
void operator delete[]( void*, void* ) {}
96
97
#endif
98
102
#define ODRX_NO_HEAP_OPERATORS() \
103
void* operator new(size_t ) throw() { ODA_FAIL(); return 0; }\
104
void operator delete(void* ) { ODA_FAIL(); std::terminate(); }\
105
void* operator new[](size_t ) throw() { ODA_FAIL(); return 0; }\
106
void operator delete[](void* ) { ODA_FAIL(); std::terminate(); }
107
108
#ifdef OD_REDEFINE_HEAP_OPERATORS
109
113
#define ODRX_USING_HEAP_OPERATORS(T) \
114
void* operator new(size_t s) throw() { return T::operator new(s); }\
115
void operator delete(void* p) { T::operator delete(p); }\
116
void* operator new[](size_t s) throw() { return T::operator new(s); }\
117
void operator delete[](void* p) { T::operator delete(p); }
118
119
#else
120
124
#define ODRX_USING_HEAP_OPERATORS(T) \
125
using T::operator new;\
126
using T::operator delete;\
127
using T::operator new[];\
128
using T::operator delete[]
129
130
#endif
131
132
133
#endif
// _OD_HEAPOPERATORS_INCLUDED_
OdAlloc.h
Generated on Tue Apr 15 2025 11:30:04