Lolly 1.4.28
Loading...
Searching...
No Matches
Macros | Functions
fast_alloc.hpp File Reference
#include <stdlib.h>
#include <new>
Include dependency graph for fast_alloc.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define WORD_LENGTH   8
 
#define WORD_LENGTH_INC   7
 
#define WORD_MASK   0xfffffffffffffff8
 
#define MAX_FAST   264
 
#define BLOCK_SIZE   65536
 

Functions

voidfast_alloc (size_t s)
 
void fast_free (void *ptr, size_t s)
 
voidfast_realloc (void *ptr, size_t old_size, size_t new_size)
 
voidfast_new (size_t s)
 
void fast_delete (void *ptr)
 
int mem_used ()
 
void mem_info ()
 
void mem_init ()
 
voidalloc_check (const char *msg, void *ptr, size_t *sp)
 
template<typename C >
Ctm_new ()
 
template<typename C , typename A1 >
Ctm_new (const A1 &a1)
 
template<typename C , typename A1 , typename A2 >
Ctm_new (const A1 &a1, const A2 &a2)
 
template<typename C , typename A1 , typename A2 >
Ctm_new (const A1 &a1, A2 &a2)
 
template<typename C , typename A1 , typename A2 >
Ctm_new (A1 &a1, const A2 &a2)
 
template<typename C , typename A1 , typename A2 >
Ctm_new (A1 &a1, A2 &a2)
 
template<typename C , typename A1 , typename A2 , typename A3 >
Ctm_new (const A1 &a1, const A2 &a2, const A3 &a3)
 
template<typename C , typename A1 , typename A2 , typename A3 >
Ctm_new (const A1 &a1, A2 &a2, A3 &a3)
 
template<typename C , typename A1 , typename A2 , typename A3 >
Ctm_new (A1 &a1, A2 &a2, const A3 &a3)
 
template<typename C , typename A1 , typename A2 , typename A3 >
Ctm_new (A1 &a1, A2 &a2, A3 &a3)
 
template<typename C , typename A1 , typename A2 , typename A3 , typename A4 >
Ctm_new (const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4)
 
template<typename C , typename A1 , typename A2 , typename A3 , typename A4 >
Ctm_new (const A1 &a1, A2 &a2, A3 &a3, A4 &a4)
 
template<typename C , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 >
Ctm_new (const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5)
 
template<typename C , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 >
Ctm_new (const A1 &a1, A2 &a2, A3 &a3, A4 &a4, A5 &a5)
 
template<typename C , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 >
Ctm_new (A1 &a1, A2 &a2, A3 &a3, A4 &a4, A5 &a5)
 
template<typename C , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 >
Ctm_new (const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6)
 
template<typename C , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 >
Ctm_new (A1 &a1, const A2 &a2, A3 &a3, A4 &a4, A5 &a5, A6 &a6)
 
template<typename C , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 >
Ctm_new (const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7)
 
template<typename C , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 >
Ctm_new (const A1 &a1, const A2 &a2, const A3 &a3, A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7)
 
template<typename C , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 >
Ctm_new (const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8)
 
template<typename C , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 >
Ctm_new (A1 &a1, const A2 &a2, A3 &a3, A4 &a4, A5 &a5, A6 &a6, A7 &a7, A8 &a8)
 
template<typename C , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 >
Ctm_new (const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9)
 
template<typename C , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 >
Ctm_new (const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9, const A10 &a10)
 
template<typename C , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 >
Ctm_new (const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9, const A10 &a10, const A11 &a11)
 
template<typename C , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 >
Ctm_new (const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9, const A10 &a10, const A11 &a11, const A12 &a12)
 
template<typename C , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 >
Ctm_new (const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9, const A10 &a10, const A11 &a11, const A12 &a12, const A13 &a13)
 
template<typename C , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 , typename A14 >
Ctm_new (const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9, const A10 &a10, const A11 &a11, const A12 &a12, const A13 &a13, const A14 &a14)
 
template<typename C , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 , typename A14 , typename A15 >
Ctm_new (const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9, const A10 &a10, const A11 &a11, const A12 &a12, const A13 &a13, const A14 &a14, const A15 &a15)
 
template<typename C , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 , typename A14 , typename A15 , typename A16 , typename A17 >
Ctm_new (const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9, const A10 &a10, const A11 &a11, const A12 &a12, const A13 &a13, const A14 &a14, const A15 &a15, const A16 &a16, const A17 &a17)
 
template<typename C , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 , typename A14 , typename A15 , typename A16 , typename A17 , typename A18 , typename A19 , typename A20 , typename A21 >
Ctm_new (const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9, const A10 &a10, const A11 &a11, const A12 &a12, const A13 &a13, const A14 &a14, const A15 &a15, const A16 &a16, const A17 &a17, const A18 &a18, const A19 &a19, const A20 &a20, const A21 &a21)
 
template<typename C >
void tm_delete (C *ptr)
 
template<typename C >
Ctm_new_array (int n)
 
template<typename C >
Ctm_resize_array (int new_num, C *Ptr)
 
template<typename C >
void tm_delete_array (C *Ptr)
 

Macro Definition Documentation

◆ WORD_LENGTH

#define WORD_LENGTH   8

Definition at line 16 of file fast_alloc.hpp.

◆ WORD_LENGTH_INC

#define WORD_LENGTH_INC   7

Definition at line 17 of file fast_alloc.hpp.

◆ WORD_MASK

#define WORD_MASK   0xfffffffffffffff8

Definition at line 18 of file fast_alloc.hpp.

◆ MAX_FAST

#define MAX_FAST   264

Definition at line 20 of file fast_alloc.hpp.

◆ BLOCK_SIZE

#define BLOCK_SIZE   65536

Definition at line 21 of file fast_alloc.hpp.

Function Documentation

◆ fast_alloc()

void * fast_alloc ( size_t s)
extern

Definition at line 82 of file fast_alloc.cpp.

82 {
83 sz= (sz + WORD_LENGTH_INC) & WORD_MASK;
84 if (sz < MAX_FAST) {
85 void* ptr= alloc_ptr (sz);
86 if (ptr == NULL) return enlarge_malloc (sz);
87 alloc_ptr (sz)= ind (ptr);
88#ifdef DEBUG_ON
90#endif
91 return ptr;
92 }
93 else {
94 if (MEM_DEBUG >= 3) cout << "Big alloc of " << sz << " bytes\n";
95 if (MEM_DEBUG >= 3) cout << "Memory used: " << mem_used () << " bytes\n";
96 large_uses+= sz;
97 return safe_malloc (sz);
98 }
99}
The list class represents a linked list.
Definition list.hpp:48
bool break_stub(void *ptr)
int large_uses
#define ind(ptr)
int mem_used()
#define alloc_ptr(i)
int MEM_DEBUG
void * safe_malloc(size_t sz)
void * enlarge_malloc(size_t sz)
#define WORD_LENGTH_INC
#define MAX_FAST
#define WORD_MASK
tm_ostream & cout

◆ fast_free()

void fast_free ( void * ptr,
size_t s )
extern

Definition at line 102 of file fast_alloc.cpp.

102 {
103 sz= (sz + WORD_LENGTH_INC) & WORD_MASK;
104 if (sz < MAX_FAST) {
105#ifdef DEBUG_ON
106 break_stub (ptr);
107 break_stub (alloc_ptr (sz));
108#endif
109 ind (ptr) = alloc_ptr (sz);
110 alloc_ptr (sz)= ptr;
111 }
112 else {
113 if (MEM_DEBUG >= 3) cout << "Big free of " << sz << " bytes\n";
114 large_uses-= sz;
115 free (ptr);
116 if (MEM_DEBUG >= 3) cout << "Memory used: " << mem_used () << " bytes\n";
117 }
118}

◆ fast_realloc()

void * fast_realloc ( void * ptr,
size_t old_size,
size_t new_size )
extern

Definition at line 121 of file fast_alloc.cpp.

121 {
125 if (MEM_DEBUG >= 3)
126 cout << "Big realloc from " << old_size << " to " << new_size
127 << " bytes\n";
129 if (MEM_DEBUG >= 3) cout << "Memory used: " << mem_used () << " bytes\n";
130 return realloc (ptr, new_size);
131 }
132 else {
133 void* newptr= fast_alloc (new_size);
136 return newptr;
137 }
138}
void fast_free(void *ptr, size_t sz)
void * fast_alloc(size_t sz)

◆ fast_new()

void * fast_new ( size_t s)
extern

Definition at line 141 of file fast_alloc.cpp.

141 {
142 void* ptr;
143#ifdef DEBUG_ON
144 s= (s + (4 * WORD_LENGTH) + WORD_LENGTH_INC) & WORD_MASK;
145#else
147#endif
148 if (s < MAX_FAST) {
149 ptr= alloc_ptr (s);
150 if (ptr == NULL) ptr= enlarge_malloc (s);
151 else alloc_ptr (s)= ind (ptr);
152#ifdef DEBUG_ON
153 break_stub (ptr);
154#endif
155 }
156 else {
157 if (MEM_DEBUG >= 3) cout << "Big alloc of " << s << " bytes\n";
158 if (MEM_DEBUG >= 3) cout << "Memory used: " << mem_used () << " bytes\n";
159 ptr= safe_malloc (s);
160 // if ((((int) ptr) & 15) != 0) cout << "Unaligned new " << ptr << "\n";
161 large_uses+= s;
162 }
163#ifdef DEBUG_ON
164 char* mem = (char*) ptr;
165 *((size_t*) ptr) = s;
166 ptr = ((char*) ptr) + WORD_LENGTH;
167 *((size_t*) ptr) = s;
168 ptr = ((char*) ptr) + WORD_LENGTH;
169 *((size_t*) ptr) = ~s;
170 ptr = ((char*) ptr) + WORD_LENGTH;
171 *((int*) (mem + s - WORD_LENGTH))= 0x55aa;
172 return (void*) ptr;
173#else
174 *((size_t*) ptr)= s;
175 return (void*) (((char*) ptr) + WORD_LENGTH);
176#endif
177}
#define WORD_LENGTH

◆ fast_delete()

void fast_delete ( void * ptr)
extern

Definition at line 203 of file fast_alloc.cpp.

203 {
204#ifdef DEBUG_ON
205 size_t s;
206 ptr= alloc_check ("fast_delete", ptr, &s);
207#else
208 ptr = (void*) (((char*) ptr) - WORD_LENGTH);
209 size_t s= *((size_t*) ptr);
210#endif
211 if (s < MAX_FAST) {
212#ifdef DEBUG_ON
213 break_stub (ptr);
214 break_stub (alloc_ptr (s));
215#endif
216 ind (ptr) = alloc_ptr (s);
217 alloc_ptr (s)= ptr;
218 }
219 else {
220 if (MEM_DEBUG >= 3) cout << "Big free of " << s << " bytes\n";
221 // if ((((int) ptr) & 15) != 0) cout << "Unaligned delete " << ptr << "\n";
222 free (ptr);
223 large_uses-= s;
224 if (MEM_DEBUG >= 3) cout << "Memory used: " << mem_used () << " bytes\n";
225 }
226}
void * alloc_check(const char *msg, void *ptr, size_t *sp)

◆ mem_used()

int mem_used ( )
extern

Definition at line 267 of file fast_alloc.cpp.

267 {
270 int i;
271 for (i= WORD_LENGTH; i < MAX_FAST; i+= WORD_LENGTH)
274 return small_uses + large_uses;
275}
void * alloc_table[MAX_FAST]
int fast_chunks
size_t alloc_remains
int compute_free(void *ptr)
#define BLOCK_SIZE

◆ mem_info()

void mem_info ( )
extern

Definition at line 278 of file fast_alloc.cpp.

278 {
279 cout << "\n---------------- memory statistics ----------------\n";
282 int i;
283 for (i= WORD_LENGTH; i < MAX_FAST; i+= WORD_LENGTH)
287 // cout << "Fast chunks : " << chunks_use << " bytes\n";
288 // cout << "Free on chunks: " << alloc_remains << " bytes\n";
289 cout << "User : " << total_uses << " bytes\n";
290 cout << "Allocator : " << chunks_use + large_uses << " bytes\n";
291 cout << "Small mallocs : "
292 << ((100 * ((float) small_uses)) / ((float) total_uses)) << "%\n";
293}

◆ mem_init()

void mem_init ( )
extern

Definition at line 308 of file fast_alloc.cpp.

308{}

◆ alloc_check()

void * alloc_check ( const char * msg,
void * ptr,
size_t * sp )

◆ tm_new() [1/30]

template<typename C >
C * tm_new ( )
inline

Definition at line 59 of file fast_alloc.hpp.

59 {
60 void* ptr= fast_new (sizeof (C));
61 (void) new (ptr) C ();
62 return (C*) ptr;
63}
void * fast_new(size_t s)

◆ tm_new() [2/30]

template<typename C , typename A1 >
C * tm_new ( const A1 & a1)
inline

Definition at line 67 of file fast_alloc.hpp.

67 {
68 void* ptr= fast_new (sizeof (C));
69 (void) new (ptr) C (a1);
70 return (C*) ptr;
71}

◆ tm_new() [3/30]

template<typename C , typename A1 , typename A2 >
C * tm_new ( const A1 & a1,
const A2 & a2 )
inline

Definition at line 75 of file fast_alloc.hpp.

75 {
76 void* ptr= fast_new (sizeof (C));
77 (void) new (ptr) C (a1, a2);
78 return (C*) ptr;
79}

◆ tm_new() [4/30]

template<typename C , typename A1 , typename A2 >
C * tm_new ( const A1 & a1,
A2 & a2 )
inline

Definition at line 83 of file fast_alloc.hpp.

83 {
84 void* ptr= fast_new (sizeof (C));
85 (void) new (ptr) C (a1, a2);
86 return (C*) ptr;
87}

◆ tm_new() [5/30]

template<typename C , typename A1 , typename A2 >
C * tm_new ( A1 & a1,
const A2 & a2 )
inline

Definition at line 91 of file fast_alloc.hpp.

91 {
92 void* ptr= fast_new (sizeof (C));
93 (void) new (ptr) C (a1, a2);
94 return (C*) ptr;
95}

◆ tm_new() [6/30]

template<typename C , typename A1 , typename A2 >
C * tm_new ( A1 & a1,
A2 & a2 )
inline

Definition at line 99 of file fast_alloc.hpp.

99 {
100 void* ptr= fast_new (sizeof (C));
101 (void) new (ptr) C (a1, a2);
102 return (C*) ptr;
103}

◆ tm_new() [7/30]

template<typename C , typename A1 , typename A2 , typename A3 >
C * tm_new ( const A1 & a1,
const A2 & a2,
const A3 & a3 )
inline

Definition at line 107 of file fast_alloc.hpp.

107 {
108 void* ptr= fast_new (sizeof (C));
109 (void) new (ptr) C (a1, a2, a3);
110 return (C*) ptr;
111}

◆ tm_new() [8/30]

template<typename C , typename A1 , typename A2 , typename A3 >
C * tm_new ( const A1 & a1,
A2 & a2,
A3 & a3 )
inline

Definition at line 115 of file fast_alloc.hpp.

115 {
116 void* ptr= fast_new (sizeof (C));
117 (void) new (ptr) C (a1, a2, a3);
118 return (C*) ptr;
119}

◆ tm_new() [9/30]

template<typename C , typename A1 , typename A2 , typename A3 >
C * tm_new ( A1 & a1,
A2 & a2,
const A3 & a3 )
inline

Definition at line 123 of file fast_alloc.hpp.

123 {
124 void* ptr= fast_new (sizeof (C));
125 (void) new (ptr) C (a1, a2, a3);
126 return (C*) ptr;
127}

◆ tm_new() [10/30]

template<typename C , typename A1 , typename A2 , typename A3 >
C * tm_new ( A1 & a1,
A2 & a2,
A3 & a3 )
inline

Definition at line 131 of file fast_alloc.hpp.

131 {
132 void* ptr= fast_new (sizeof (C));
133 (void) new (ptr) C (a1, a2, a3);
134 return (C*) ptr;
135}

◆ tm_new() [11/30]

C * tm_new ( const A1 & a1,
const A2 & a2,
const A3 & a3,
const A4 & a4 )
inline

Definition at line 139 of file fast_alloc.hpp.

139 {
140 void* ptr= fast_new (sizeof (C));
141 (void) new (ptr) C (a1, a2, a3, a4);
142 return (C*) ptr;
143}

◆ tm_new() [12/30]

C * tm_new ( const A1 & a1,
A2 & a2,
A3 & a3,
A4 & a4 )
inline

Definition at line 147 of file fast_alloc.hpp.

147 {
148 void* ptr= fast_new (sizeof (C));
149 (void) new (ptr) C (a1, a2, a3, a4);
150 return (C*) ptr;
151}

◆ tm_new() [13/30]

C * tm_new ( const A1 & a1,
const A2 & a2,
const A3 & a3,
const A4 & a4,
const A5 & a5 )
inline

Definition at line 156 of file fast_alloc.hpp.

156 {
157 void* ptr= fast_new (sizeof (C));
158 (void) new (ptr) C (a1, a2, a3, a4, a5);
159 return (C*) ptr;
160}

◆ tm_new() [14/30]

C * tm_new ( const A1 & a1,
A2 & a2,
A3 & a3,
A4 & a4,
A5 & a5 )
inline

Definition at line 165 of file fast_alloc.hpp.

165 {
166 void* ptr= fast_new (sizeof (C));
167 (void) new (ptr) C (a1, a2, a3, a4, a5);
168 return (C*) ptr;
169}

◆ tm_new() [15/30]

C * tm_new ( A1 & a1,
A2 & a2,
A3 & a3,
A4 & a4,
A5 & a5 )
inline

Definition at line 174 of file fast_alloc.hpp.

174 {
175 void* ptr= fast_new (sizeof (C));
176 (void) new (ptr) C (a1, a2, a3, a4, a5);
177 return (C*) ptr;
178}

◆ tm_new() [16/30]

C * tm_new ( const A1 & a1,
const A2 & a2,
const A3 & a3,
const A4 & a4,
const A5 & a5,
const A6 & a6 )
inline

Definition at line 183 of file fast_alloc.hpp.

184 {
185 void* ptr= fast_new (sizeof (C));
186 (void) new (ptr) C (a1, a2, a3, a4, a5, a6);
187 return (C*) ptr;
188}

◆ tm_new() [17/30]

C * tm_new ( A1 & a1,
const A2 & a2,
A3 & a3,
A4 & a4,
A5 & a5,
A6 & a6 )
inline

Definition at line 193 of file fast_alloc.hpp.

193 {
194 void* ptr= fast_new (sizeof (C));
195 (void) new (ptr) C (a1, a2, a3, a4, a5, a6);
196 return (C*) ptr;
197}

◆ tm_new() [18/30]

C * tm_new ( const A1 & a1,
const A2 & a2,
const A3 & a3,
const A4 & a4,
const A5 & a5,
const A6 & a6,
const A7 & a7 )
inline

Definition at line 202 of file fast_alloc.hpp.

203 {
204 void* ptr= fast_new (sizeof (C));
205 (void) new (ptr) C (a1, a2, a3, a4, a5, a6, a7);
206 return (C*) ptr;
207}

◆ tm_new() [19/30]

C * tm_new ( const A1 & a1,
const A2 & a2,
const A3 & a3,
A4 & a4,
const A5 & a5,
const A6 & a6,
const A7 & a7 )
inline

Definition at line 212 of file fast_alloc.hpp.

213 {
214 void* ptr= fast_new (sizeof (C));
215 (void) new (ptr) C (a1, a2, a3, a4, a5, a6, a7);
216 return (C*) ptr;
217}

◆ tm_new() [20/30]

C * tm_new ( const A1 & a1,
const A2 & a2,
const A3 & a3,
const A4 & a4,
const A5 & a5,
const A6 & a6,
const A7 & a7,
const A8 & a8 )
inline

Definition at line 222 of file fast_alloc.hpp.

223 {
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}

◆ tm_new() [21/30]

C * tm_new ( A1 & a1,
const A2 & a2,
A3 & a3,
A4 & a4,
A5 & a5,
A6 & a6,
A7 & a7,
A8 & a8 )
inline

Definition at line 232 of file fast_alloc.hpp.

232 {
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}

◆ tm_new() [22/30]

C * tm_new ( const A1 & a1,
const A2 & a2,
const A3 & a3,
const A4 & a4,
const A5 & a5,
const A6 & a6,
const A7 & a7,
const A8 & a8,
const A9 & a9 )
inline

Definition at line 241 of file fast_alloc.hpp.

242 {
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}

◆ tm_new() [23/30]

C * tm_new ( const A1 & a1,
const A2 & a2,
const A3 & a3,
const A4 & a4,
const A5 & a5,
const A6 & a6,
const A7 & a7,
const A8 & a8,
const A9 & a9,
const A10 & a10 )
inline

Definition at line 252 of file fast_alloc.hpp.

254 {
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}

◆ tm_new() [24/30]

C * tm_new ( const A1 & a1,
const A2 & a2,
const A3 & a3,
const A4 & a4,
const A5 & a5,
const A6 & a6,
const A7 & a7,
const A8 & a8,
const A9 & a9,
const A10 & a10,
const A11 & a11 )
inline

Definition at line 264 of file fast_alloc.hpp.

266 {
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}

◆ tm_new() [25/30]

C * tm_new ( const A1 & a1,
const A2 & a2,
const A3 & a3,
const A4 & a4,
const A5 & a5,
const A6 & a6,
const A7 & a7,
const A8 & a8,
const A9 & a9,
const A10 & a10,
const A11 & a11,
const A12 & a12 )
inline

Definition at line 276 of file fast_alloc.hpp.

278 {
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}

◆ tm_new() [26/30]

C * tm_new ( const A1 & a1,
const A2 & a2,
const A3 & a3,
const A4 & a4,
const A5 & a5,
const A6 & a6,
const A7 & a7,
const A8 & a8,
const A9 & a9,
const A10 & a10,
const A11 & a11,
const A12 & a12,
const A13 & a13 )
inline

Definition at line 288 of file fast_alloc.hpp.

290 {
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}

◆ tm_new() [27/30]

C * tm_new ( const A1 & a1,
const A2 & a2,
const A3 & a3,
const A4 & a4,
const A5 & a5,
const A6 & a6,
const A7 & a7,
const A8 & a8,
const A9 & a9,
const A10 & a10,
const A11 & a11,
const A12 & a12,
const A13 & a13,
const A14 & a14 )
inline

Definition at line 300 of file fast_alloc.hpp.

302 {
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}

◆ tm_new() [28/30]

C * tm_new ( const A1 & a1,
const A2 & a2,
const A3 & a3,
const A4 & a4,
const A5 & a5,
const A6 & a6,
const A7 & a7,
const A8 & a8,
const A9 & a9,
const A10 & a10,
const A11 & a11,
const A12 & a12,
const A13 & a13,
const A14 & a14,
const A15 & a15 )
inline

Definition at line 314 of file fast_alloc.hpp.

317 {
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}

◆ tm_new() [29/30]

C * tm_new ( const A1 & a1,
const A2 & a2,
const A3 & a3,
const A4 & a4,
const A5 & a5,
const A6 & a6,
const A7 & a7,
const A8 & a8,
const A9 & a9,
const A10 & a10,
const A11 & a11,
const A12 & a12,
const A13 & a13,
const A14 & a14,
const A15 & a15,
const A16 & a16,
const A17 & a17 )
inline

Definition at line 329 of file fast_alloc.hpp.

332 {
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}

◆ tm_new() [30/30]

C * tm_new ( const A1 & a1,
const A2 & a2,
const A3 & a3,
const A4 & a4,
const A5 & a5,
const A6 & a6,
const A7 & a7,
const A8 & a8,
const A9 & a9,
const A10 & a10,
const A11 & a11,
const A12 & a12,
const A13 & a13,
const A14 & a14,
const A15 & a15,
const A16 & a16,
const A17 & a17,
const A18 & a18,
const A19 & a19,
const A20 & a20,
const A21 & a21 )
inline

Definition at line 345 of file fast_alloc.hpp.

349 {
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}

◆ tm_delete()

template<typename C >
void tm_delete ( C * ptr)
inline

Definition at line 358 of file fast_alloc.hpp.

358 {
359 ptr->~C ();
360 fast_delete ((void*) ptr);
361}
void fast_delete(void *ptr)

◆ tm_new_array()

template<typename C >
C * tm_new_array ( int n)
inline

Definition at line 408 of file fast_alloc.hpp.

408 {
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}
void * fast_alloc(size_t s)

◆ tm_resize_array()

template<typename C >
C * tm_resize_array ( int new_num,
C * Ptr )
inline

Definition at line 419 of file fast_alloc.hpp.

419 {
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}
void * fast_realloc(void *ptr, size_t old_size, size_t new_size)

◆ tm_delete_array()

template<typename C >
void tm_delete_array ( C * Ptr)
inline

Definition at line 435 of file fast_alloc.hpp.

435 {
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}
void fast_free(void *ptr, size_t s)