InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
MemoryStatics.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: ?
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //========================================================================================
23 
24 #ifndef __MemoryStatics__
25 #define __MemoryStatics__
26 
27 // This definition is checked for elsewhere as a sanity check to make sure we aren't
28 // missing this header (and thus missing our new/delete) in InDesign / plug-in code.
29 
30 #define INCLUDED_MEMORY_STATICS 1
31 
32 #ifndef INTERNAL_TEST_WITH_PLATFORM_ALLOCATOR
33 
34 #ifdef WINDOWS
35 
36 // On Windows, these are exported from PMRuntime.
37 // NOT CURRENTLY TRUE: On the Mac, these are in MemoryStatics.cpp which is present in (but not exported from) each linkage unit
38 
39 void* operator new(size_t size);
40 
41 void* operator new[](size_t size);
42 
43 void operator delete(void*p) noexcept;
44 
45 void operator delete[](void*p) noexcept;
46 
47 void* operator new(size_t size, const std::nothrow_t&) noexcept;
48 
49 void* operator new[](size_t size, const std::nothrow_t&) noexcept;
50 
51 void operator delete(void*p, const std::nothrow_t&) noexcept;
52 
53 void operator delete[](void*p, const std::nothrow_t&) noexcept;
54 
55 void * operator new(size_t size, short temporary); // [][] get rid of these, temporary memory does nothing special anymore
56 
57 void * operator new[](size_t size, short temporary); // [][] get rid of these, temporary memory does nothing special anymore
58 
59 #endif
60 
61 #ifdef MACINTOSH
62 #ifdef __cplusplus
63 #include <new>
64 
65 namespace K2Memory // in PMRuntime
66 {
67  __attribute__ ((visibility("default"))) void *RTLCompatibleNewDelegate (size_t size);
68 
69  __attribute__ ((visibility("default"))) void *RTLCompatibleNewArrayDelegate (size_t size);
70 
71  __attribute__ ((visibility("default"))) void RTLCompatibleDeleteDelegate (void *p);
72 
73  __attribute__ ((visibility("default"))) void RTLCompatibleDeleteArrayDelegate (void *p);
74 };
75 
76 // These new and delete operators must be forced inline, because if code is actually
77 // generated for them, new and delete are always default visibility and they will
78 // be exported from where they are generated, which causes link problems with libraries, etc...
79 
80 // both "inline" and "__attribute__ ((__always_inline__))" are reqyured
81 #define FORCE_INLINE inline __attribute__ ((__always_inline__))
82 
83 FORCE_INLINE void* operator new(std::size_t size)
84 {
85  // Doesn't actually throw
86  return K2Memory::RTLCompatibleNewDelegate (size);
87 }
88 
89 FORCE_INLINE void* operator new[](std::size_t size)
90 {
91  // Doesn't actually throw
92  return K2Memory::RTLCompatibleNewArrayDelegate (size);
93 }
94 
95 FORCE_INLINE void operator delete(void*p) noexcept
96 {
97  K2Memory::RTLCompatibleDeleteDelegate (p);
98 }
99 
100 FORCE_INLINE void operator delete[](void*p) noexcept
101 {
102  K2Memory::RTLCompatibleDeleteArrayDelegate (p);
103 }
104 
105 FORCE_INLINE void operator delete(void*p, std::size_t) noexcept
106 {
107  K2Memory::RTLCompatibleDeleteDelegate(p);
108 }
109 
110 FORCE_INLINE void operator delete[](void*p, std::size_t) noexcept
111 {
112  K2Memory::RTLCompatibleDeleteArrayDelegate(p);
113 }
114 
115 
116 FORCE_INLINE void* operator new(std::size_t size, const std::nothrow_t&) noexcept
117 {
118  return K2Memory::RTLCompatibleNewDelegate (size);
119 }
120 
121 FORCE_INLINE void* operator new[](std::size_t size, const std::nothrow_t&) noexcept
122 {
123  return K2Memory::RTLCompatibleNewArrayDelegate (size);
124 }
125 
126 FORCE_INLINE void operator delete(void*p, const std::nothrow_t&) noexcept
127 {
128  K2Memory::RTLCompatibleDeleteDelegate (p);
129 }
130 
131 FORCE_INLINE void operator delete[](void*p, const std::nothrow_t&) noexcept
132 {
133  K2Memory::RTLCompatibleDeleteArrayDelegate (p);
134 }
135 
136 FORCE_INLINE void * operator new(std::size_t size, short temporary)
137 {
138  // [][] get rid of these, temporary memory does nothing special anymore
139  return K2Memory::RTLCompatibleNewDelegate (size);
140 }
141 
142 FORCE_INLINE void * operator new[](std::size_t size, short temporary)
143 {
144  // [][] get rid of these, temporary memory does nothing special anymore
145  return K2Memory::RTLCompatibleNewArrayDelegate (size);
146 }
147 
148 #endif
149 
150 #endif // MACINTOSH
151 
152 #endif // !INTERNAL_TEST_WITH_PLATFORM_ALLOCATOR
153 
154 #endif // __MemoryStatics__
155 
156