1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
/*
Copyright 1990-2008 Light Infocon Tecnologia S/A
Este arquivo é parte do programa LightBase - Banco de Dados Textual Documental
O LightBase é um software livre; você pode redistribui-lo e/ou modifica-lo dentro
dos termos da Licença Pública Geral GNU como publicada pela Fundação do Software
Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO
EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU versao 2, sob o
título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do
Software Livre(FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//
// void * ALStatus::operator new( size_t size )
//
// ARGUMENTS:
//
// size : The number of bytes needed to create a new ALStatus object.
//
// RETURNS
//
// A pointer to the newly allocated storage area, or 0 if no storage
// was available.
//
// DESCRIPTION
//
// When using a DLL, it is easy to get into a dangerous situation when
// creating objects whose ctor and dtor are both in the DLL. The problem
// arises because when you create an object using new, the memory for
// the object will be allocated from the EXE. However, when you destroy
// the object using delete, the memory is freed inside the DLL. Since
// the DLL doesn't really own that memory, bad things can happen.
//
// But, you say, won't the space just go back to the Windows heap regardless
// of who tries to free it? Maybe, but maybe not. If the DLL is using
// a subsegment allocation scheme, it might do some sort of local free
// before returning the space to the windows heap. That is the point where
// you could conceivably cook your heap.
//
// By providing our own version of operator new inside this class, we
// ensure that all memory allocation for the class will be done from
// inside the DLL, not the EXE calling the DLL.
//
// REVISION HISTORY
//
// May 26, 1994 1.0A : First release
//
void AL_DLL_FAR * AL_PROTO ALStatus::operator new
//
// ALStatus::ALStatus()
//
// ARGUMENTS:
//
// None.
//
// RETURNS
//
// Nothing, this is a constructor.
//
// DESCRIPTION
//
// This is the only constructor for objects of class ALStatus. It
// initializes the detail length member to 129, which is a const and
// won't change. The initial status is AL_SUCCESS, and there is no
// detail string to start with.
//
// REVISION HISTORY
//
// May 26, 1994 1.0A : First release
//
AL_PROTO :
//
// ALStatus::~ALStatus()
//
// ARGUMENTS:
//
// None, destructor.
//
// RETURNS
//
// None, destructor.
//
// DESCRIPTION
//
// The destructor has to free up any space allocated for the detailed
// error status string. That's all.
//
// REVISION HISTORY
//
// May 26, 1994 1.0A : First release
//
AL_PROTO ALStatus::~
//
// int ALStatus::SetError( int error, const char AL_DLL_FAR *fmt, ... )
//
// ARGUMENTS:
//
// error : The new error code to set the miStatus member to. A value
// less than 0 (AL_SUCCESS) will always be interpreted as
// an error.
//
// fmt : A sprintf style formatting string. This is for the
// message that is going to go into the status detail message.
//
// ... : Any additional arguments needed by the formatting string.
//
//
// RETURNS
//
// error, the error code that just got passed in.
//
// DESCRIPTION
//
// I don't know why I did the status detail allocation the way it is
// done here, it is really stupid. I should just allocate whatever space
// is necessary after formatting the string. This will probably be
// fixed in 1.x.
//
// This function is used to set the status of an object to an error state.
// Normally this is done by sending an error code, along with a detailed
// message explaining what went wrong and why. Note that to clear
// and error state, you can pass AL_SUCCESS for the error code and
// 0 for the format. The object will look like it is healthy and happy
// after that.
//
// REVISION HISTORY
//
// May 26, 1994 1.0A : First release
//
int AL_PROTO
//
// const char * ALStatus::GetStatusString()
//
// ARGUMENTS:
//
// None.
//
// RETURNS
//
// A short ASCII translation of the current error code.
//
// DESCRIPTION
//
// Rather than just printing an error code number, it is usually more
// helpful to translate that number into ASCII text, so a user or
// programmer can read the description. This function is used to
// do just that. It translates the current error code into a short
// ASCII text string. Note that this is not the same as the detail
// string, which is tailored for each specific occurrence of an error code.
//
// REVISION HISTORY
//
// May 26, 1994 1.0A : First release
//
const char AL_DLL_FAR * AL_PROTO
//
// const char * ALStatus::GetStatusDetail() const
//
// ARGUMENTS:
//
// None.
//
// RETURNS
//
// Guaranteed to return a valid character string.
//
// DESCRIPTION
//
// Whenever we set the error code for an object in ArchiveLib, we
// call ALStatus::SetError(). At the same time that we set the
// error code of the object to a non-zero value, we supply a formatted
// string providing some detail about when and where the error
// took place, maybe even including some other information provided by the
// O/S. That information is stored in the detail string, which is a
// private data member. This function provides the ability to get at
// that detail string.
//
// REVISION HISTORY
//
// May 26, 1994 1.0A : First release
//
const char AL_DLL_FAR * AL_PROTO
//
// ALStatus & ALStatus::operator = ( ALStatus &rhs )
//
// ARGUMENTS:
//
// rhs : Another ALStatus object that I want to copy into this object.
//
// RETURNS
//
// A reference to this.
//
// DESCRIPTION
//
// Somewhere in ArchiveLib I want to be able to copy one status
// into another. This function does just that. It has to allocate
// new space to make a copy of the detail string, and be sure to
// free up any old space, and all that.
//
// REVISION HISTORY
//
// May 26, 1994 1.0A : First release
//
ALStatus AL_DLL_FAR & AL_PROTO