Lolly 1.4.28
Loading...
Searching...
No Matches
fast_alloc.hpp
Go to the documentation of this file.
1
2/******************************************************************************
3 * MODULE : fast_alloc.hpp
4 * DESCRIPTION: see fast_alloc.cpp
5 * COPYRIGHT : (C) 1999 Joris van der Hoeven
6 *******************************************************************************
7 * This software falls under the GNU general public license version 3 or later.
8 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
9 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
10 ******************************************************************************/
11
12#ifndef FAST_ALLOC_H
13#define FAST_ALLOC_H
14
15#include <stdlib.h>
16#define WORD_LENGTH 8
17#define WORD_LENGTH_INC 7
18#define WORD_MASK 0xfffffffffffffff8
19// WORD_LENGTH more than power of 2
20#define MAX_FAST 264
21#define BLOCK_SIZE 65536 // should be >>> MAX_FAST
22
23/******************************************************************************
24 * General purpose fast allocation routines
25 ******************************************************************************/
26
27extern void* fast_alloc (size_t s);
28extern void fast_free (void* ptr, size_t s);
29extern void* fast_realloc (void* ptr, size_t old_size, size_t new_size);
30extern void* fast_new (size_t s);
31extern void fast_delete (void* ptr);
32
33extern int mem_used ();
34extern void mem_info ();
35extern void mem_init ();
36void* alloc_check (const char* msg, void* ptr, size_t* sp);
37
38/******************************************************************************
39 * Fast new and delete
40 ******************************************************************************/
41
42#if (!defined(NO_FAST_ALLOC)) && (!defined(X11TEXMACS))
43
44#ifdef OLD_GNU_COMPILER
45inline void*
46operator new (size_t s, void* loc) {
47 return loc;
48}
49inline void*
50operator new[] (size_t s, void* loc) {
51 return loc;
52}
53#else
54#include <new>
55#endif
56
57template <typename C>
58inline C*
60 void* ptr= fast_new (sizeof (C));
61 (void) new (ptr) C ();
62 return (C*) ptr;
63}
64
65template <typename C, typename A1>
66inline C*
67tm_new (const A1& a1) {
68 void* ptr= fast_new (sizeof (C));
69 (void) new (ptr) C (a1);
70 return (C*) ptr;
71}
72
73template <typename C, typename A1, typename A2>
74inline C*
75tm_new (const A1& a1, const A2& a2) {
76 void* ptr= fast_new (sizeof (C));
77 (void) new (ptr) C (a1, a2);
78 return (C*) ptr;
79}
80
81template <typename C, typename A1, typename A2>
82inline C*
83tm_new (const A1& a1, A2& a2) {
84 void* ptr= fast_new (sizeof (C));
85 (void) new (ptr) C (a1, a2);
86 return (C*) ptr;
87}
88
89template <typename C, typename A1, typename A2>
90inline C*
91tm_new (A1& a1, const A2& a2) {
92 void* ptr= fast_new (sizeof (C));
93 (void) new (ptr) C (a1, a2);
94 return (C*) ptr;
95}
96
97template <typename C, typename A1, typename A2>
98inline C*
100 void* ptr= fast_new (sizeof (C));
101 (void) new (ptr) C (a1, a2);
102 return (C*) ptr;
103}
104
105template <typename C, typename A1, typename A2, typename A3>
106inline C*
107tm_new (const A1& a1, const A2& a2, const A3& a3) {
108 void* ptr= fast_new (sizeof (C));
109 (void) new (ptr) C (a1, a2, a3);
110 return (C*) ptr;
111}
112
113template <typename C, typename A1, typename A2, typename A3>
114inline C*
115tm_new (const A1& a1, A2& a2, A3& a3) {
116 void* ptr= fast_new (sizeof (C));
117 (void) new (ptr) C (a1, a2, a3);
118 return (C*) ptr;
119}
120
121template <typename C, typename A1, typename A2, typename A3>
122inline C*
123tm_new (A1& a1, A2& a2, const A3& a3) {
124 void* ptr= fast_new (sizeof (C));
125 (void) new (ptr) C (a1, a2, a3);
126 return (C*) ptr;
127}
128
129template <typename C, typename A1, typename A2, typename A3>
130inline C*
131tm_new (A1& a1, A2& a2, A3& a3) {
132 void* ptr= fast_new (sizeof (C));
133 (void) new (ptr) C (a1, a2, a3);
134 return (C*) ptr;
135}
136
137template <typename C, typename A1, typename A2, typename A3, typename A4>
138inline C*
139tm_new (const A1& a1, const A2& a2, const A3& a3, const A4& a4) {
140 void* ptr= fast_new (sizeof (C));
141 (void) new (ptr) C (a1, a2, a3, a4);
142 return (C*) ptr;
143}
144
145template <typename C, typename A1, typename A2, typename A3, typename A4>
146inline C*
147tm_new (const A1& a1, A2& a2, A3& a3, A4& a4) {
148 void* ptr= fast_new (sizeof (C));
149 (void) new (ptr) C (a1, a2, a3, a4);
150 return (C*) ptr;
151}
152
153template <typename C, typename A1, typename A2, typename A3, typename A4,
154 typename A5>
155inline C*
156tm_new (const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5) {
157 void* ptr= fast_new (sizeof (C));
158 (void) new (ptr) C (a1, a2, a3, a4, a5);
159 return (C*) ptr;
160}
161
162template <typename C, typename A1, typename A2, typename A3, typename A4,
163 typename A5>
164inline C*
165tm_new (const A1& a1, A2& a2, A3& a3, A4& a4, A5& a5) {
166 void* ptr= fast_new (sizeof (C));
167 (void) new (ptr) C (a1, a2, a3, a4, a5);
168 return (C*) ptr;
169}
170
171template <typename C, typename A1, typename A2, typename A3, typename A4,
172 typename A5>
173inline C*
174tm_new (A1& a1, A2& a2, A3& a3, A4& a4, A5& a5) {
175 void* ptr= fast_new (sizeof (C));
176 (void) new (ptr) C (a1, a2, a3, a4, a5);
177 return (C*) ptr;
178}
179
180template <typename C, typename A1, typename A2, typename A3, typename A4,
181 typename A5, typename A6>
182inline C*
183tm_new (const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5,
184 const A6& a6) {
185 void* ptr= fast_new (sizeof (C));
186 (void) new (ptr) C (a1, a2, a3, a4, a5, a6);
187 return (C*) ptr;
188}
189
190template <typename C, typename A1, typename A2, typename A3, typename A4,
191 typename A5, typename A6>
192inline C*
193tm_new (A1& a1, const A2& a2, A3& a3, A4& a4, A5& a5, A6& a6) {
194 void* ptr= fast_new (sizeof (C));
195 (void) new (ptr) C (a1, a2, a3, a4, a5, a6);
196 return (C*) ptr;
197}
198
199template <typename C, typename A1, typename A2, typename A3, typename A4,
200 typename A5, typename A6, typename A7>
201inline C*
202tm_new (const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5,
203 const A6& a6, const A7& a7) {
204 void* ptr= fast_new (sizeof (C));
205 (void) new (ptr) C (a1, a2, a3, a4, a5, a6, a7);
206 return (C*) ptr;
207}
208
209template <typename C, typename A1, typename A2, typename A3, typename A4,
210 typename A5, typename A6, typename A7>
211inline C*
212tm_new (const A1& a1, const A2& a2, const A3& a3, A4& a4, const A5& a5,
213 const A6& a6, const A7& a7) {
214 void* ptr= fast_new (sizeof (C));
215 (void) new (ptr) C (a1, a2, a3, a4, a5, a6, a7);
216 return (C*) ptr;
217}
218
219template <typename C, typename A1, typename A2, typename A3, typename A4,
220 typename A5, typename A6, typename A7, typename A8>
221inline C*
222tm_new (const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5,
223 const A6& a6, const A7& a7, const A8& a8) {
224 void* ptr= fast_new (sizeof (C));
225 (void) new (ptr) C (a1, a2, a3, a4, a5, a6, a7, a8);
226 return (C*) ptr;
227}
228
229template <typename C, typename A1, typename A2, typename A3, typename A4,
230 typename A5, typename A6, typename A7, typename A8>
231inline C*
232tm_new (A1& a1, const A2& a2, A3& a3, A4& a4, A5& a5, A6& a6, A7& a7, A8& a8) {
233 void* ptr= fast_new (sizeof (C));
234 (void) new (ptr) C (a1, a2, a3, a4, a5, a6, a7, a8);
235 return (C*) ptr;
236}
237
238template <typename C, typename A1, typename A2, typename A3, typename A4,
239 typename A5, typename A6, typename A7, typename A8, typename A9>
240inline C*
241tm_new (const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5,
242 const A6& a6, const A7& a7, const A8& a8, const A9& a9) {
243 void* ptr= fast_new (sizeof (C));
244 (void) new (ptr) C (a1, a2, a3, a4, a5, a6, a7, a8, a9);
245 return (C*) ptr;
246}
247
248template <typename C, typename A1, typename A2, typename A3, typename A4,
249 typename A5, typename A6, typename A7, typename A8, typename A9,
250 typename A10>
251inline C*
252tm_new (const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5,
253 const A6& a6, const A7& a7, const A8& a8, const A9& a9,
254 const A10& a10) {
255 void* ptr= fast_new (sizeof (C));
256 (void) new (ptr) C (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
257 return (C*) ptr;
258}
259
260template <typename C, typename A1, typename A2, typename A3, typename A4,
261 typename A5, typename A6, typename A7, typename A8, typename A9,
262 typename A10, typename A11>
263inline C*
264tm_new (const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5,
265 const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A10& a10,
266 const A11& a11) {
267 void* ptr= fast_new (sizeof (C));
268 (void) new (ptr) C (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11);
269 return (C*) ptr;
270}
271
272template <typename C, typename A1, typename A2, typename A3, typename A4,
273 typename A5, typename A6, typename A7, typename A8, typename A9,
274 typename A10, typename A11, typename A12>
275inline C*
276tm_new (const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5,
277 const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A10& a10,
278 const A11& a11, const A12& a12) {
279 void* ptr= fast_new (sizeof (C));
280 (void) new (ptr) C (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12);
281 return (C*) ptr;
282}
283
284template <typename C, typename A1, typename A2, typename A3, typename A4,
285 typename A5, typename A6, typename A7, typename A8, typename A9,
286 typename A10, typename A11, typename A12, typename A13>
287inline C*
288tm_new (const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5,
289 const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A10& a10,
290 const A11& a11, const A12& a12, const A13& a13) {
291 void* ptr= fast_new (sizeof (C));
292 (void) new (ptr) C (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13);
293 return (C*) ptr;
294}
295
296template <typename C, typename A1, typename A2, typename A3, typename A4,
297 typename A5, typename A6, typename A7, typename A8, typename A9,
298 typename A10, typename A11, typename A12, typename A13, typename A14>
299inline C*
300tm_new (const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5,
301 const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A10& a10,
302 const A11& a11, const A12& a12, const A13& a13, const A14& a14) {
303 void* ptr= fast_new (sizeof (C));
304 (void) new (ptr)
305 C (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14);
306 return (C*) ptr;
307}
308
309template <typename C, typename A1, typename A2, typename A3, typename A4,
310 typename A5, typename A6, typename A7, typename A8, typename A9,
311 typename A10, typename A11, typename A12, typename A13, typename A14,
312 typename A15>
313inline C*
314tm_new (const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5,
315 const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A10& a10,
316 const A11& a11, const A12& a12, const A13& a13, const A14& a14,
317 const A15& a15) {
318 void* ptr= fast_new (sizeof (C));
319 (void) new (ptr)
320 C (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15);
321 return (C*) ptr;
322}
323
324template <typename C, typename A1, typename A2, typename A3, typename A4,
325 typename A5, typename A6, typename A7, typename A8, typename A9,
326 typename A10, typename A11, typename A12, typename A13, typename A14,
327 typename A15, typename A16, typename A17>
328inline C*
329tm_new (const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5,
330 const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A10& a10,
331 const A11& a11, const A12& a12, const A13& a13, const A14& a14,
332 const A15& a15, const A16& a16, const A17& a17) {
333 void* ptr= fast_new (sizeof (C));
334 (void) new (ptr) C (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13,
335 a14, a15, a16, a17);
336 return (C*) ptr;
337}
338
339template <typename C, typename A1, typename A2, typename A3, typename A4,
340 typename A5, typename A6, typename A7, typename A8, typename A9,
341 typename A10, typename A11, typename A12, typename A13, typename A14,
342 typename A15, typename A16, typename A17, typename A18, typename A19,
343 typename A20, typename A21>
344inline C*
345tm_new (const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5,
346 const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A10& a10,
347 const A11& a11, const A12& a12, const A13& a13, const A14& a14,
348 const A15& a15, const A16& a16, const A17& a17, const A18& a18,
349 const A19& a19, const A20& a20, const A21& a21) {
350 void* ptr= fast_new (sizeof (C));
351 (void) new (ptr) C (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13,
352 a14, a15, a16, a17, a18, a19, a20, a21);
353 return (C*) ptr;
354}
355
356template <typename C>
357inline void
359 ptr->~C ();
360 fast_delete ((void*) ptr);
361}
362
363#ifdef DEBUG_ON
364template <typename C>
365C*
366tm_new_array (int n) {
367 void* ptr = fast_alloc (n * sizeof (C) + (4 * WORD_LENGTH));
368 *((int*) ptr)= n;
369 ptr = (void*) (((char*) ptr) + WORD_LENGTH);
370 *((int*) ptr)= n;
371 ptr = (void*) (((char*) ptr) + WORD_LENGTH);
372 *((int*) ptr)= ~n;
373 ptr = (void*) (((char*) ptr) + WORD_LENGTH);
374 C* ctr = (C*) ptr;
375 for (int i= 0; i < n; i++, ctr++)
376 (void) new ((void*) ctr) C ();
377 *((int*) ctr)= 0x55AA;
378 return (C*) ptr;
379}
380
381template <typename C>
382void
384 void* ptr= (void*) Ptr;
385 ptr = (void*) (((char*) ptr) - WORD_LENGTH);
386 int comp = *((int*) ptr);
387 ptr = (void*) (((char*) ptr) - WORD_LENGTH);
388 int n1 = *((int*) ptr);
389 ptr = (void*) (((char*) ptr) - WORD_LENGTH);
390 int n = *((int*) ptr);
391 if ((n1 + comp) != -1 || (n + comp) != -1) {
392 printf ("tm_delete_array size mismatch: %d:%d vs %d:%d\n", n, n + comp, n1,
393 n1 + comp);
394 }
395
396 C* ctr= Ptr + n;
397 if (*((int*) ctr) != 0x55AA) {
398 printf ("tm_delete_array buffer overflow\n");
399 }
400 ctr--;
401 for (int i= 0; i < n; i++, ctr--)
402 ctr->~C ();
403 fast_free (ptr, n * sizeof (C) + (4 * WORD_LENGTH));
404}
405#else
406template <typename C>
407inline C*
409 void* ptr = fast_alloc (n * sizeof (C) + WORD_LENGTH);
410 *((int*) ptr)= n;
411 ptr = (void*) (((char*) ptr) + WORD_LENGTH);
412 C* ctr = (C*) ptr;
413 for (int i= 0; i < n; i++, ctr++)
414 (void) new ((void*) ctr) C ();
415 return (C*) ptr;
416}
417template <typename C>
418inline C*
420 void* old_arr = (void*) Ptr;
421 old_arr = (void*) (((char*) old_arr) - WORD_LENGTH);
422 int old_num = *((int*) old_arr);
423 void* new_arr = fast_realloc (old_arr, old_num * sizeof (C) + WORD_LENGTH,
424 new_num * sizeof (C) + WORD_LENGTH);
425 *((int*) new_arr)= new_num;
426 new_arr = (void*) (((char*) new_arr) + WORD_LENGTH);
427 C* ctr = (C*) new_arr + old_num;
428 for (int i= old_num; i < new_num; i++, ctr++)
429 (void) new ((void*) ctr) C ();
430 return (C*) new_arr;
431}
432
433template <typename C>
434inline void
436 void* ptr= (void*) Ptr;
437 ptr = (void*) (((char*) ptr) - WORD_LENGTH);
438 int n = *((int*) ptr);
439 C* ctr = Ptr + n - 1;
440 for (int i= 0; i < n; i++, ctr--)
441 ctr->~C ();
442 fast_free (ptr, n * sizeof (C) + WORD_LENGTH);
443}
444#endif
445
446#endif // (!defined(NO_FAST_ALLOC)) && (!defined(X11TEXMACS))
447
448/******************************************************************************
449 * Slow new and delete
450 ******************************************************************************/
451
452#if defined(NO_FAST_ALLOC) || defined(X11TEXMACS)
453
454#ifndef NO_FAST_ALLOC
455#ifdef OS_IRIX
456void* operator new (size_t s) throw (std::bad_alloc);
457void operator delete (void* ptr) throw ();
458void* operator new[] (size_t s) throw (std::bad_alloc);
459void operator delete[] (void* ptr) throw ();
460#else
461void* operator new (size_t s);
462void operator delete (void* ptr);
463void* operator new[] (size_t s);
464void operator delete[] (void* ptr);
465#endif
466#endif // not defined NO_FAST_ALLOC
467
468template <typename C>
469inline C*
470tm_new () {
471 return new C ();
472}
473
474template <typename C, typename A1>
475inline C*
476tm_new (const A1& a1) {
477 return new C (a1);
478}
479
480template <typename C, typename A1, typename A2>
481inline C*
482tm_new (const A1& a1, const A2& a2) {
483 return new C (a1, a2);
484}
485
486template <typename C, typename A1, typename A2>
487inline C*
488tm_new (const A1& a1, A2& a2) {
489 return new C (a1, a2);
490}
491
492template <typename C, typename A1, typename A2>
493inline C*
494tm_new (A1& a1, const A2& a2) {
495 return new C (a1, a2);
496}
497
498template <typename C, typename A1, typename A2>
499inline C*
500tm_new (A1& a1, A2& a2) {
501 return new C (a1, a2);
502}
503
504template <typename C, typename A1, typename A2, typename A3>
505inline C*
506tm_new (const A1& a1, const A2& a2, const A3& a3) {
507 return new C (a1, a2, a3);
508}
509
510template <typename C, typename A1, typename A2, typename A3>
511inline C*
512tm_new (const A1& a1, A2& a2, A3& a3) {
513 return new C (a1, a2, a3);
514}
515
516template <typename C, typename A1, typename A2, typename A3>
517inline C*
518tm_new (A1& a1, A2& a2, const A3& a3) {
519 return new C (a1, a2, a3);
520}
521
522template <typename C, typename A1, typename A2, typename A3>
523inline C*
524tm_new (A1& a1, A2& a2, A3& a3) {
525 return new C (a1, a2, a3);
526}
527
528template <typename C, typename A1, typename A2, typename A3, typename A4>
529inline C*
530tm_new (const A1& a1, const A2& a2, const A3& a3, const A4& a4) {
531 return new C (a1, a2, a3, a4);
532}
533
534template <typename C, typename A1, typename A2, typename A3, typename A4>
535inline C*
536tm_new (const A1& a1, A2& a2, A3& a3, A4& a4) {
537 return new C (a1, a2, a3, a4);
538}
539
540template <typename C, typename A1, typename A2, typename A3, typename A4,
541 typename A5>
542inline C*
543tm_new (const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5) {
544 return new C (a1, a2, a3, a4, a5);
545}
546
547template <typename C, typename A1, typename A2, typename A3, typename A4,
548 typename A5>
549inline C*
550tm_new (const A1& a1, A2& a2, A3& a3, A4& a4, A5& a5) {
551 return new C (a1, a2, a3, a4, a5);
552}
553
554template <typename C, typename A1, typename A2, typename A3, typename A4,
555 typename A5>
556inline C*
557tm_new (A1& a1, A2& a2, A3& a3, A4& a4, A5& a5) {
558 return new C (a1, a2, a3, a4, a5);
559}
560
561template <typename C, typename A1, typename A2, typename A3, typename A4,
562 typename A5, typename A6>
563inline C*
564tm_new (const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5,
565 const A6& a6) {
566 return new C (a1, a2, a3, a4, a5, a6);
567}
568
569template <typename C, typename A1, typename A2, typename A3, typename A4,
570 typename A5, typename A6>
571inline C*
572tm_new (A1& a1, const A2& a2, A3& a3, A4& a4, A5& a5, A6& a6) {
573 return new C (a1, a2, a3, a4, a5, a6);
574}
575
576template <typename C, typename A1, typename A2, typename A3, typename A4,
577 typename A5, typename A6, typename A7>
578inline C*
579tm_new (const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5,
580 const A6& a6, const A7& a7) {
581 return new C (a1, a2, a3, a4, a5, a6, a7);
582}
583
584template <typename C, typename A1, typename A2, typename A3, typename A4,
585 typename A5, typename A6, typename A7>
586inline C*
587tm_new (const A1& a1, const A2& a2, const A3& a3, A4& a4, const A5& a5,
588 const A6& a6, const A7& a7) {
589 return new C (a1, a2, a3, a4, a5, a6, a7);
590}
591
592template <typename C, typename A1, typename A2, typename A3, typename A4,
593 typename A5, typename A6, typename A7, typename A8>
594inline C*
595tm_new (const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5,
596 const A6& a6, const A7& a7, const A8& a8) {
597 return new C (a1, a2, a3, a4, a5, a6, a7, a8);
598}
599
600template <typename C, typename A1, typename A2, typename A3, typename A4,
601 typename A5, typename A6, typename A7, typename A8>
602inline C*
603tm_new (A1& a1, const A2& a2, A3& a3, A4& a4, A5& a5, A6& a6, A7& a7, A8& a8) {
604 return new C (a1, a2, a3, a4, a5, a6, a7, a8);
605}
606
607template <typename C, typename A1, typename A2, typename A3, typename A4,
608 typename A5, typename A6, typename A7, typename A8, typename A9>
609inline C*
610tm_new (const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5,
611 const A6& a6, const A7& a7, const A8& a8, const A9& a9) {
612 return new C (a1, a2, a3, a4, a5, a6, a7, a8, a9);
613}
614
615template <typename C, typename A1, typename A2, typename A3, typename A4,
616 typename A5, typename A6, typename A7, typename A8, typename A9,
617 typename A10>
618inline C*
619tm_new (const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5,
620 const A6& a6, const A7& a7, const A8& a8, const A9& a9,
621 const A10& a10) {
622 return new C (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
623}
624
625template <typename C, typename A1, typename A2, typename A3, typename A4,
626 typename A5, typename A6, typename A7, typename A8, typename A9,
627 typename A10, typename A11>
628inline C*
629tm_new (const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5,
630 const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A10& a10,
631 const A11& a11) {
632 return new C (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11);
633}
634
635template <typename C, typename A1, typename A2, typename A3, typename A4,
636 typename A5, typename A6, typename A7, typename A8, typename A9,
637 typename A10, typename A11, typename A12>
638inline C*
639tm_new (const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5,
640 const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A10& a10,
641 const A11& a11, const A12& a12) {
642 return new C (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12);
643}
644
645template <typename C, typename A1, typename A2, typename A3, typename A4,
646 typename A5, typename A6, typename A7, typename A8, typename A9,
647 typename A10, typename A11, typename A12, typename A13>
648inline C*
649tm_new (const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5,
650 const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A10& a10,
651 const A11& a11, const A12& a12, const A13& a13) {
652 return new C (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13);
653}
654
655template <typename C, typename A1, typename A2, typename A3, typename A4,
656 typename A5, typename A6, typename A7, typename A8, typename A9,
657 typename A10, typename A11, typename A12, typename A13, typename A14>
658inline C*
659tm_new (const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5,
660 const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A10& a10,
661 const A11& a11, const A12& a12, const A13& a13, const A14& a14) {
662 return new C (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14);
663}
664
665template <typename C, typename A1, typename A2, typename A3, typename A4,
666 typename A5, typename A6, typename A7, typename A8, typename A9,
667 typename A10, typename A11, typename A12, typename A13, typename A14,
668 typename A15>
669inline C*
670tm_new (const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5,
671 const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A10& a10,
672 const A11& a11, const A12& a12, const A13& a13, const A14& a14,
673 const A15& a15) {
674 return new C (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14,
675 a15);
676}
677
678template <typename C, typename A1, typename A2, typename A3, typename A4,
679 typename A5, typename A6, typename A7, typename A8, typename A9,
680 typename A10, typename A11, typename A12, typename A13, typename A14,
681 typename A15, typename A16, typename A17, typename A18, typename A19,
682 typename A20, typename A21>
683inline C*
684tm_new (const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5,
685 const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A10& a10,
686 const A11& a11, const A12& a12, const A13& a13, const A14& a14,
687 const A15& a15, const A16& a16, const A17& a17, const A18& a18,
688 const A19& a19, const A20& a20, const A21& a21) {
689 return new C (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14,
690 a15, a16, a17, a18, a19, a20, a21);
691}
692
693template <typename C>
694inline void
695tm_delete (C* ptr) {
696 delete ptr;
697}
698
699template <typename C>
700inline C*
701tm_new_array (int n) {
702 return new C[n];
703}
704
705template <typename C>
706inline void
708 delete[] Ptr;
709}
710
711#endif // defined(NO_FAST_ALLOC) || defined(X11TEXMACS)
712
713#endif // defined FAST_ALLOC_H
The list class represents a linked list.
Definition list.hpp:48
list(T item)
Construct a new list object with a single item.
Definition list.hpp:137
void * fast_realloc(void *ptr, size_t old_size, size_t new_size)
C * tm_resize_array(int new_num, C *Ptr)
void mem_info()
void fast_free(void *ptr, size_t s)
void fast_delete(void *ptr)
#define WORD_LENGTH
C * tm_new_array(int n)
int mem_used()
void * fast_new(size_t s)
C * tm_new()
void mem_init()
void * fast_alloc(size_t s)
void * alloc_check(const char *msg, void *ptr, size_t *sp)
void tm_delete(C *ptr)
void tm_delete_array(C *Ptr)