2 |
7u83 |
1 |
/*
|
|
|
2 |
Crown Copyright (c) 1997
|
|
|
3 |
|
|
|
4 |
This TenDRA(r) Computer Program is subject to Copyright
|
|
|
5 |
owned by the United Kingdom Secretary of State for Defence
|
|
|
6 |
acting through the Defence Evaluation and Research Agency
|
|
|
7 |
(DERA). It is made available to Recipients with a
|
|
|
8 |
royalty-free licence for its use, reproduction, transfer
|
|
|
9 |
to other parties and amendment for any purpose not excluding
|
|
|
10 |
product development provided that any such use et cetera
|
|
|
11 |
shall be deemed to be acceptance of the following conditions:-
|
|
|
12 |
|
|
|
13 |
(1) Its Recipients shall ensure that this Notice is
|
|
|
14 |
reproduced upon any copies or amended versions of it;
|
|
|
15 |
|
|
|
16 |
(2) Any amended version of it shall be clearly marked to
|
|
|
17 |
show both the nature of and the organisation responsible
|
|
|
18 |
for the relevant amendment or amendments;
|
|
|
19 |
|
|
|
20 |
(3) Its onward transfer from a recipient to another
|
|
|
21 |
party shall be deemed to be that party's acceptance of
|
|
|
22 |
these conditions;
|
|
|
23 |
|
|
|
24 |
(4) DERA gives no warranty or assurance as to its
|
|
|
25 |
quality or suitability for any purpose and DERA accepts
|
|
|
26 |
no liability whatsoever in relation to any use to which
|
|
|
27 |
it may be put.
|
|
|
28 |
*/
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
#include "implement.h"
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
/*
|
|
|
35 |
FUNCTION SELECTION MACROS
|
|
|
36 |
|
|
|
37 |
The eight memory allocation and deallocation routines defined in this
|
|
|
38 |
file are replaceable. In order to allow them to be replaced
|
|
|
39 |
independently they are compiled separately by defining the following
|
|
|
40 |
four macros.
|
|
|
41 |
*/
|
|
|
42 |
|
|
|
43 |
#ifndef NEW
|
|
|
44 |
#define NEW 0
|
|
|
45 |
#endif
|
|
|
46 |
|
|
|
47 |
#ifndef DELETE
|
|
|
48 |
#define DELETE 0
|
|
|
49 |
#endif
|
|
|
50 |
|
|
|
51 |
#ifndef ARRAY
|
|
|
52 |
#define ARRAY 0
|
|
|
53 |
#endif
|
|
|
54 |
|
|
|
55 |
#ifndef NOTHROW
|
|
|
56 |
#define NOTHROW 0
|
|
|
57 |
#endif
|
|
|
58 |
|
|
|
59 |
|
|
|
60 |
/*
|
|
|
61 |
STANDARD MEMORY ALLOCATION FUNCTION
|
|
|
62 |
|
|
|
63 |
This routine allocates sz bytes of memory. It needs to be in a
|
|
|
64 |
separate source file to allow it to be replaced in a simple fashion.
|
|
|
65 |
*/
|
|
|
66 |
|
|
|
67 |
#if ( NEW && !ARRAY && !NOTHROW )
|
|
|
68 |
|
|
|
69 |
void *operator new ( size_t sz ) throw ( bad_alloc )
|
|
|
70 |
{
|
|
|
71 |
return ( __TCPPLUS_new ( sz ) ) ;
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
#endif
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
/*
|
|
|
78 |
STANDARD ARRAY MEMORY ALLOCATION FUNCTION
|
|
|
79 |
|
|
|
80 |
This routine allocates sz bytes of memory for use as an array. It
|
|
|
81 |
needs to be in a separate source file to allow it to be replaced
|
|
|
82 |
in a simple fashion.
|
|
|
83 |
*/
|
|
|
84 |
|
|
|
85 |
#if ( NEW && ARRAY && !NOTHROW )
|
|
|
86 |
|
|
|
87 |
void *operator new [] ( size_t sz ) throw ( bad_alloc )
|
|
|
88 |
{
|
|
|
89 |
return ( operator new ( sz ) ) ;
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
#endif
|
|
|
93 |
|
|
|
94 |
|
|
|
95 |
/*
|
|
|
96 |
STANDARD MEMORY DEALLOCATION FUNCTION
|
|
|
97 |
|
|
|
98 |
This routine deallocates the memory given by p. It needs to be in
|
|
|
99 |
a separate source file to allow it to be replaced in a simple fashion.
|
|
|
100 |
*/
|
|
|
101 |
|
|
|
102 |
#if ( DELETE && !ARRAY && !NOTHROW )
|
|
|
103 |
|
|
|
104 |
void operator delete ( void *p ) throw ()
|
|
|
105 |
{
|
|
|
106 |
__TCPPLUS_delete ( p ) ;
|
|
|
107 |
return ;
|
|
|
108 |
}
|
|
|
109 |
|
|
|
110 |
#endif
|
|
|
111 |
|
|
|
112 |
|
|
|
113 |
/*
|
|
|
114 |
STANDARD ARRAY MEMORY DEALLOCATION FUNCTION
|
|
|
115 |
|
|
|
116 |
This routine deallocates the array memory given by p. It needs to be
|
|
|
117 |
in a separate source file to allow it to be replaced in a simple fashion.
|
|
|
118 |
*/
|
|
|
119 |
|
|
|
120 |
#if ( DELETE && ARRAY && !NOTHROW )
|
|
|
121 |
|
|
|
122 |
void operator delete [] ( void *p ) throw ()
|
|
|
123 |
{
|
|
|
124 |
operator delete ( p ) ;
|
|
|
125 |
return ;
|
|
|
126 |
}
|
|
|
127 |
|
|
|
128 |
#endif
|
|
|
129 |
|
|
|
130 |
|
|
|
131 |
/*
|
|
|
132 |
NO-EXCEPTION MEMORY ALLOCATION FUNCTION
|
|
|
133 |
|
|
|
134 |
This routine allocates sz bytes of memory returning the null pointer
|
|
|
135 |
rather than throwing an exception if memory allocation fails. It
|
|
|
136 |
needs to be in a separate source file to allow it to be replaced in
|
|
|
137 |
a simple fashion.
|
|
|
138 |
*/
|
|
|
139 |
|
|
|
140 |
#if ( NEW && !ARRAY && NOTHROW )
|
|
|
141 |
|
|
|
142 |
void *operator new ( size_t sz, const nothrow_t & ) throw ()
|
|
|
143 |
{
|
|
|
144 |
return ( __TCPPLUS_new_nothrow ( sz ) ) ;
|
|
|
145 |
}
|
|
|
146 |
|
|
|
147 |
#endif
|
|
|
148 |
|
|
|
149 |
|
|
|
150 |
/*
|
|
|
151 |
NO-EXCEPTION ARRAY MEMORY ALLOCATION FUNCTION
|
|
|
152 |
|
|
|
153 |
This routine allocates sz bytes of memory for use as an array
|
|
|
154 |
returning the null pointer rather than throwing an exception if
|
|
|
155 |
memory allocation fails. It needs to be in a separate source file
|
|
|
156 |
to allow it to be replaced in a simple fashion.
|
|
|
157 |
*/
|
|
|
158 |
|
|
|
159 |
#if ( NEW && ARRAY && NOTHROW )
|
|
|
160 |
|
|
|
161 |
void *operator new [] ( size_t sz, const nothrow_t & ) throw ()
|
|
|
162 |
{
|
|
|
163 |
return ( operator new ( sz, nothrow ) ) ;
|
|
|
164 |
}
|
|
|
165 |
|
|
|
166 |
#endif
|
|
|
167 |
|
|
|
168 |
|
|
|
169 |
/*
|
|
|
170 |
NO-EXCEPTION MEMORY DEALLOCATION FUNCTION
|
|
|
171 |
|
|
|
172 |
This routine is the placement delete matching the no-exception operator
|
|
|
173 |
new which deallocates the memory given by p. It needs to be in a
|
|
|
174 |
separate source file to allow it to be replaced in a simple fashion.
|
|
|
175 |
*/
|
|
|
176 |
|
|
|
177 |
#if ( DELETE && !ARRAY && NOTHROW )
|
|
|
178 |
|
|
|
179 |
void operator delete ( void *p, const nothrow_t & ) throw ()
|
|
|
180 |
{
|
|
|
181 |
__TCPPLUS_delete ( p ) ;
|
|
|
182 |
return ;
|
|
|
183 |
}
|
|
|
184 |
|
|
|
185 |
#endif
|
|
|
186 |
|
|
|
187 |
|
|
|
188 |
/*
|
|
|
189 |
NO-EXCEPTION ARRAY MEMORY DEALLOCATION FUNCTION
|
|
|
190 |
|
|
|
191 |
This routine is the placement delete matching the no-exception operator
|
|
|
192 |
new [] which deallocates the array memory given by p. It needs to be
|
|
|
193 |
in a separate source file to allow it to be replaced in a simple fashion.
|
|
|
194 |
*/
|
|
|
195 |
|
|
|
196 |
#if ( DELETE && ARRAY && NOTHROW )
|
|
|
197 |
|
|
|
198 |
void operator delete [] ( void *p, const nothrow_t & ) throw ()
|
|
|
199 |
{
|
|
|
200 |
operator delete ( p, nothrow ) ;
|
|
|
201 |
return ;
|
|
|
202 |
}
|
|
|
203 |
|
|
|
204 |
#endif
|