foobar2000 SDK  2015-01-14
alloc.h
Go to the documentation of this file.
1 namespace pfc {
2 
3  static void * raw_malloc(t_size p_size) {
4  return p_size > 0 ? new_ptr_check_t(malloc(p_size)) : NULL;
5  }
6 
7  static void raw_free(void * p_block) throw() {free(p_block);}
8 
9  static void* raw_realloc(void * p_ptr,t_size p_size) {
10  if (p_size == 0) {raw_free(p_ptr); return NULL;}
11  else if (p_ptr == NULL) return raw_malloc(p_size);
12  else return pfc::new_ptr_check_t(::realloc(p_ptr,p_size));
13  }
14 
15  static bool raw_realloc_inplace(void * p_block,t_size p_size) throw() {
16  if (p_block == NULL) return p_size == 0;
17 #ifdef _MSC_VER
18  if (p_size == 0) return false;
19  return _expand(p_block,p_size) != NULL;
20 #else
21  return false;
22 #endif
23  }
24 
25  template<typename T>
27  return pfc::mul_safe_t<std::bad_alloc,t_size>(p_width,sizeof(T));
28  }
29 
30  template<typename T>
31  T * __raw_malloc_t(t_size p_size) {
32  return reinterpret_cast<T*>(raw_malloc(calc_array_width<T>(p_size)));
33  }
34 
35  template<typename T>
36  void __raw_free_t(T * p_block) throw() {
37  raw_free(reinterpret_cast<void*>(p_block));
38  }
39 
40  template<typename T>
41  T * __raw_realloc_t(T * p_block,t_size p_size) {
42  return reinterpret_cast<T*>(raw_realloc(p_block,calc_array_width<T>(p_size)));
43  }
44 
45  template<typename T>
46  bool __raw_realloc_inplace_t(T * p_block,t_size p_size) {
47  return raw_realloc_inplace(p_block,calc_array_width<T>(p_size));
48  }
49 
50 
51  template<typename t_exception,typename t_int>
52  inline t_int safe_shift_left_t(t_int p_val,t_size p_shift = 1) {
53  t_int newval = p_val << p_shift;
54  if (newval >> p_shift != p_val) throw t_exception();
55  return newval;
56  }
57 
58  template<typename t_item> class alloc_dummy {
59  private: typedef alloc_dummy<t_item> t_self;
60  public:
62  void set_size(t_size p_size) {throw pfc::exception_not_implemented();}
63  t_size get_size() const {throw pfc::exception_not_implemented();}
64  const t_item & operator[](t_size p_index) const {throw pfc::exception_not_implemented();}
65  t_item & operator[](t_size p_index) {throw pfc::exception_not_implemented();}
66 
67  bool is_ptr_owned(const void * p_item) const {return false;}
68 
69  //set to true when we prioritize speed over memory usage
70  enum { alloc_prioritizes_speed = false };
71 
72  //not mandatory
73  const t_item * get_ptr() const {throw pfc::exception_not_implemented();}
74  t_item * get_ptr() {throw pfc::exception_not_implemented();}
75  void prealloc(t_size) {throw pfc::exception_not_implemented();}
76  void force_reset() {throw pfc::exception_not_implemented();}
77  void move_from(t_self &) {throw pfc::exception_not_implemented();}
78  private:
79  const t_self & operator=(const t_self &) {throw pfc::exception_not_implemented();}
80  alloc_dummy(const t_self&) {throw pfc::exception_not_implemented();}
81  };
82 
83  template<typename t_item>
84  bool is_pointer_in_range(const t_item * p_buffer,t_size p_buffer_size,const void * p_pointer) {
85  return p_pointer >= reinterpret_cast<const void*>(p_buffer) && p_pointer < reinterpret_cast<const void*>(p_buffer + p_buffer_size);
86  }
87 
88 
90  template<typename t_item> class alloc_simple {
91  private: typedef alloc_simple<t_item> t_self;
92  public:
93  alloc_simple() : m_data(NULL), m_size(0) {}
94  void set_size(t_size p_size) {
95  if (p_size != m_size) {
96  t_item * l_data = NULL;
97  if (p_size > 0) l_data = new t_item[p_size];
98  try {
99  pfc::memcpy_t(l_data,m_data,pfc::min_t(m_size,p_size));
100  } catch(...) {
101  delete[] l_data;
102  throw;
103  }
104  delete[] m_data;
105  m_data = l_data;
106  m_size = p_size;
107  }
108  }
109  t_size get_size() const {return m_size;}
110  const t_item & operator[](t_size p_index) const {PFC_ASSERT(p_index < m_size); return m_data[p_index];}
111  t_item & operator[](t_size p_index) {PFC_ASSERT(p_index < m_size); return m_data[p_index];}
112  bool is_ptr_owned(const void * p_item) const {return is_pointer_in_range(get_ptr(),get_size(),p_item);}
113 
114  enum { alloc_prioritizes_speed = false };
115 
116  t_item * get_ptr() {return m_data;}
117  const t_item * get_ptr() const {return m_data;}
118 
119  void prealloc(t_size) {}
120  void force_reset() {set_size(0);}
121 
122  ~alloc_simple() {delete[] m_data;}
123 
124  void move_from(t_self & other) {
125  delete[] m_data;
126  m_data = replace_null_t(other.m_data);
127  m_size = replace_null_t(other.m_size);
128  }
129  private:
130  const t_self & operator=(const t_self &) {throw pfc::exception_not_implemented();}
131  alloc_simple(const t_self&) {throw pfc::exception_not_implemented();}
132 
133  t_item * m_data;
135  };
136 
137  template<typename t_item> class __array_fast_helper_t {
138  private:
140  public:
142 
143 
144  void set_size(t_size p_size,t_size p_size_total) {
145  PFC_ASSERT(p_size <= p_size_total);
146  PFC_ASSERT(m_size <= m_size_total);
147  if (p_size_total > m_size_total) {
148  resize_storage(p_size_total);
149  resize_content(p_size);
150  } else {
151  resize_content(p_size);
152  resize_storage(p_size_total);
153  }
154  }
155 
156 
157 
158  t_size get_size() const {return m_size;}
160  const t_item & operator[](t_size p_index) const {PFC_ASSERT(p_index < m_size); return m_buffer[p_index];}
161  t_item & operator[](t_size p_index) {PFC_ASSERT(p_index < m_size); return m_buffer[p_index];}
163  set_size(0,0);
164  }
165  t_item * get_ptr() {return m_buffer;}
166  const t_item * get_ptr() const {return m_buffer;}
167  bool is_ptr_owned(const void * p_item) const {return is_pointer_in_range(m_buffer,m_size_total,p_item);}
168 
169  void move_from(t_self & other) {
170  set_size(0,0);
171  m_buffer = replace_null_t(other.m_buffer);
172  m_size = replace_null_t(other.m_size);
173  m_size_total = replace_null_t(other.m_size_total);
174  }
175  private:
176  const t_self & operator=(const t_self &) {throw pfc::exception_not_implemented();}
177  __array_fast_helper_t(const t_self &) {throw pfc::exception_not_implemented();}
178 
179 
180  void resize_content(t_size p_size) {
182  if (p_size > m_size) {//expand
183  do {
185  m_size++;
186  } while(m_size < p_size);
187  } else if (p_size < m_size) {
189  m_size = p_size;
190  }
191  } else {
192  m_size = p_size;
193  }
194  }
195 
196  void resize_storage(t_size p_size) {
197  PFC_ASSERT( m_size <= m_size_total );
198  PFC_ASSERT( m_size <= p_size );
199  if (m_size_total != p_size) {
202  m_size_total = p_size;
203  } else if (__raw_realloc_inplace_t(m_buffer,p_size)) {
204  //success
205  m_size_total = p_size;
206  } else {
207  t_item * newbuffer = pfc::__raw_malloc_t<t_item>(p_size);
208  try {
210  } catch(...) {
211  pfc::__raw_free_t(newbuffer);
212  throw;
213  }
216  m_buffer = newbuffer;
217  m_size_total = p_size;
218  }
219  }
220  }
221 
222  t_item * m_buffer;
224  };
225 
226  template<typename t_item> class __array_lite_helper_t {
227  private:
229  public:
231 
232 
233  void set_size(t_size p_size) {
234  if (p_size > m_size) { // expand
235  resize_storage(p_size);
236  resize_content(p_size);
237  } else if (p_size < m_size) { // shrink
238  resize_content(p_size);
239  resize_storage(p_size);
240  }
241  }
242 
243 
244 
245  t_size get_size() const {return m_size;}
246  const t_item & operator[](t_size p_index) const {PFC_ASSERT(p_index < m_size); return m_buffer[p_index];}
247  t_item & operator[](t_size p_index) {PFC_ASSERT(p_index < m_size); return m_buffer[p_index];}
249  set_size(0);
250  }
251  t_item * get_ptr() {return m_buffer;}
252  const t_item * get_ptr() const {return m_buffer;}
253  bool is_ptr_owned(const void * p_item) const {return is_pointer_in_range(m_buffer,m_size,p_item);}
254 
255  void move_from(t_self & other) {
256  set_size(0);
257  m_buffer = replace_null_t(other.m_buffer);
258  m_size = replace_null_t(other.m_size);
259  }
260  private:
261  const t_self & operator=(const t_self &) {throw pfc::exception_not_implemented();}
262  __array_lite_helper_t(const t_self &) {throw pfc::exception_not_implemented();}
263 
264 
265  void resize_content(t_size p_size) {
267  if (p_size > m_size) {//expand
268  do {
270  m_size++;
271  } while(m_size < p_size);
272  } else if (p_size < m_size) {
274  m_size = p_size;
275  }
276  } else {
277  m_size = p_size;
278  }
279  }
280 
281  void resize_storage(t_size p_size) {
282  PFC_ASSERT( m_size <= p_size );
285  //m_size_total = p_size;
286  } else if (__raw_realloc_inplace_t(m_buffer,p_size)) {
287  //success
288  //m_size_total = p_size;
289  } else {
290  t_item * newbuffer = pfc::__raw_malloc_t<t_item>(p_size);
291  try {
293  } catch(...) {
294  pfc::__raw_free_t(newbuffer);
295  throw;
296  }
299  m_buffer = newbuffer;
300  //m_size_total = p_size;
301  }
302  }
303 
304  t_item * m_buffer;
306  };
307 
308  template<typename t_item> class alloc_standard {
309  private: typedef alloc_standard<t_item> t_self;
310  public:
312  void set_size(t_size p_size) {m_content.set_size(p_size);}
313 
314  t_size get_size() const {return m_content.get_size();}
315 
316  const t_item & operator[](t_size p_index) const {return m_content[p_index];}
317  t_item & operator[](t_size p_index) {return m_content[p_index];}
318 
319  const t_item * get_ptr() const {return m_content.get_ptr();}
320  t_item * get_ptr() {return m_content.get_ptr();}
321 
322  bool is_ptr_owned(const void * p_item) const {return m_content.is_ptr_owned(p_item);}
323  void prealloc(t_size p_size) {}
324  void force_reset() {set_size(0);}
325 
326  enum { alloc_prioritizes_speed = false };
327 
328  void move_from(t_self & other) { m_content.move_from(other.m_content); }
329  private:
330  alloc_standard(const t_self &) {throw pfc::exception_not_implemented();}
331  const t_self & operator=(const t_self&) {throw pfc::exception_not_implemented();}
332 
334  };
335 
336  template<typename t_item> class alloc_fast {
337  private: typedef alloc_fast<t_item> t_self;
338  public:
340 
341  void set_size(t_size p_size) {
342  t_size size_base = m_data.get_size_total();
343  if (size_base == 0) size_base = 1;
344  while(size_base < p_size) {
345  size_base = safe_shift_left_t<std::bad_alloc,t_size>(size_base,1);
346  }
347  while(size_base >> 2 > p_size) {
348  size_base >>= 1;
349  }
350  m_data.set_size(p_size,size_base);
351  }
352 
353  t_size get_size() const {return m_data.get_size();}
354  const t_item & operator[](t_size p_index) const {return m_data[p_index];}
355  t_item & operator[](t_size p_index) {return m_data[p_index];}
356 
357  const t_item * get_ptr() const {return m_data.get_ptr();}
358  t_item * get_ptr() {return m_data.get_ptr();}
359  bool is_ptr_owned(const void * p_item) const {return m_data.is_ptr_owned(p_item);}
360  void prealloc(t_size) {}
361  void force_reset() {m_data.set_size(0,0);}
362 
363  enum { alloc_prioritizes_speed = true };
364 
365  void move_from(t_self & other) { m_data.move_from(other.m_data); }
366  private:
367  alloc_fast(const t_self &) {throw pfc::exception_not_implemented();}
368  const t_self & operator=(const t_self&) {throw pfc::exception_not_implemented();}
370  };
371 
372  template<typename t_item> class alloc_fast_aggressive {
374  public:
376 
377  void set_size(t_size p_size) {
378  t_size size_base = m_data.get_size_total();
379  if (size_base == 0) size_base = 1;
380  while(size_base < p_size) {
381  size_base = safe_shift_left_t<std::bad_alloc,t_size>(size_base,1);
382  }
383  m_data.set_size(p_size,size_base);
384  }
385 
386  void prealloc(t_size p_size) {
387  if (p_size > 0) {
388  t_size size_base = m_data.get_size_total();
389  if (size_base == 0) size_base = 1;
390  while(size_base < p_size) {
391  size_base = safe_shift_left_t<std::bad_alloc,t_size>(size_base,1);
392  }
393  m_data.set_size(m_data.get_size(),size_base);
394  }
395  }
396 
397  t_size get_size() const {return m_data.get_size();}
398  const t_item & operator[](t_size p_index) const {;return m_data[p_index];}
399  t_item & operator[](t_size p_index) {return m_data[p_index];}
400 
401  const t_item * get_ptr() const {return m_data.get_ptr();}
402  t_item * get_ptr() {return m_data.get_ptr();}
403  bool is_ptr_owned(const void * p_item) const {return m_data.is_ptr_owned(p_item);}
404  void force_reset() {m_data.set_size(0,0);}
405 
406  enum { alloc_prioritizes_speed = true };
407 
408  void move_from(t_self & other) { m_data.move_from(other.m_data); }
409  private:
410  alloc_fast_aggressive(const t_self &) {throw pfc::exception_not_implemented();}
411  const t_self & operator=(const t_self&) {throw pfc::exception_not_implemented();}
413  };
414 
415  template<t_size p_width> class alloc_fixed {
416  public:
417  template<typename t_item> class alloc {
418  private: typedef alloc<t_item> t_self;
419  public:
420  alloc() : m_size(0) {}
421 
422  void set_size(t_size p_size) {
424 
425  if (p_size > p_width) throw pfc::exception_overflow();
426  else if (p_size > m_size) {
428  m_size = p_size;
429  } else if (p_size < m_size) {
431  m_size = p_size;
432  }
433  }
434 
435  ~alloc() {
437  }
438 
439  t_size get_size() const {return m_size;}
440 
441  t_item * get_ptr() {return reinterpret_cast<t_item*>(&m_array);}
442  const t_item * get_ptr() const {return reinterpret_cast<const t_item*>(&m_array);}
443 
444  const t_item & operator[](t_size n) const {return get_ptr()[n];}
445  t_item & operator[](t_size n) {return get_ptr()[n];}
446  bool is_ptr_owned(const void * p_item) const {return is_pointer_in_range(get_ptr(),p_width,p_item);}
447  void prealloc(t_size) {}
448  void force_reset() {set_size(0);}
449 
450  enum { alloc_prioritizes_speed = false };
451 
452  void move_from(t_self & other) {
453  const size_t count = other.get_size();
454  set_size( count );
455  for(size_t w = 0; w < count; ++w) this->get_ptr()[w] = other.get_ptr()[w];
456  }
457  private:
458  alloc(const t_self&) {throw pfc::exception_not_implemented();}
459  const t_self& operator=(const t_self&) {throw pfc::exception_not_implemented();}
460 
461  t_uint8 m_array[sizeof(t_item[p_width])];
463  };
464  };
465 
466  template<t_size p_width, template<typename> class t_alloc = alloc_standard > class alloc_hybrid {
467  public:
468  template<typename t_item> class alloc {
469  private: typedef alloc<t_item> t_self;
470  public:
471  alloc() {}
472 
473  void set_size(t_size p_size) {
474  if (p_size > p_width) {
475  m_fixed.set_size(p_width);
476  m_variable.set_size(p_size - p_width);
477  } else {
478  m_fixed.set_size(p_size);
479  m_variable.set_size(0);
480  }
481  }
482 
483  t_item & operator[](t_size p_index) {
484  PFC_ASSERT(p_index < get_size());
485  if (p_index < p_width) return m_fixed[p_index];
486  else return m_variable[p_index - p_width];
487  }
488 
489  const t_item & operator[](t_size p_index) const {
490  PFC_ASSERT(p_index < get_size());
491  if (p_index < p_width) return m_fixed[p_index];
492  else return m_variable[p_index - p_width];
493  }
494 
495  t_size get_size() const {return m_fixed.get_size() + m_variable.get_size();}
496  bool is_ptr_owned(const void * p_item) const {return m_fixed.is_ptr_owned(p_item) || m_variable.is_ptr_owned(p_item);}
497  void prealloc(t_size p_size) {
498  if (p_size > p_width) m_variable.prealloc(p_size - p_width);
499  }
500  void force_reset() {
501  m_fixed.force_reset(); m_variable.force_reset();
502  }
503  enum { alloc_prioritizes_speed = t_alloc<t_item>::alloc_prioritizes_speed };
504 
505  void move_from(t_self & other) {
506  m_fixed.move_from(other.m_fixed);
507  m_variable.move_from(other.m_variable);
508  }
509  private:
510  alloc(const t_self&) {throw pfc::exception_not_implemented();}
511  const t_self& operator=(const t_self&) {throw pfc::exception_not_implemented();}
512 
515  };
516  };
517 
518  template<typename t_item> class traits_t<alloc_simple<t_item> > : public traits_default_movable {};
519  template<typename t_item> class traits_t<__array_fast_helper_t<t_item> > : public traits_default_movable {};
520  template<typename t_item> class traits_t<alloc_standard<t_item> > : public pfc::traits_t<__array_fast_helper_t<t_item> > {};
521  template<typename t_item> class traits_t<alloc_fast<t_item> > : public pfc::traits_t<__array_fast_helper_t<t_item> > {};
522  template<typename t_item> class traits_t<alloc_fast_aggressive<t_item> > : public pfc::traits_t<__array_fast_helper_t<t_item> > {};
523 
524 #if 0//not working (compiler bug?)
525  template<t_size p_width,typename t_item> class traits_t<typename alloc_fixed<p_width>::template alloc<t_item> > : public pfc::traits_t<t_item> {
526  public:
527  enum {
529  };
530  };
531 
532  template<t_size p_width,template<typename> class t_alloc,typename t_item>
533  class traits_t<typename alloc_hybrid<p_width,t_alloc>::template alloc<t_item> > : public traits_combined<t_alloc,typename alloc_fixed<p_width>::template alloc<t_item> > {};
534 #endif
535 
536 
537 };
const t_item * get_ptr() const
Definition: alloc.h:73
void set_size(t_size p_size)
Definition: alloc.h:312
const t_item * get_ptr() const
Definition: alloc.h:117
bool is_ptr_owned(const void *p_item) const
Definition: alloc.h:67
alloc(const t_self &)
Definition: alloc.h:458
alloc_fast_aggressive< t_item > t_self
Definition: alloc.h:373
void prealloc(t_size)
Definition: alloc.h:447
alloc< t_item > t_self
Definition: alloc.h:469
void set_size(t_size p_size, t_size p_size_total)
Definition: alloc.h:144
void resize_content(t_size p_size)
Definition: alloc.h:180
uint8_t t_uint8
Definition: int_types.h:9
static void raw_free(void *p_block)
Definition: alloc.h:7
alloc_simple(const t_self &)
Definition: alloc.h:131
void prealloc(t_size p_size)
Definition: alloc.h:386
bool is_ptr_owned(const void *p_item) const
Definition: alloc.h:167
void set_size(t_size p_size)
Definition: alloc.h:94
void __unsafe__in_place_destructor_array_t(t_type *p_items, t_size p_count)
Definition: primitives.h:123
t_uint8 m_array[sizeof(t_item[p_width])]
Definition: alloc.h:461
T min_t(const T &item1, const T &item2)
Definition: primitives.h:556
void move_from(t_self &)
Definition: alloc.h:77
t_size get_size() const
Definition: alloc.h:63
__array_fast_helper_t< t_item > m_data
Definition: alloc.h:412
t_size get_size() const
Definition: alloc.h:158
alloc_fast(const t_self &)
Definition: alloc.h:367
const t_item * get_ptr() const
Definition: alloc.h:319
t_type replace_null_t(t_type &p_var)
Definition: primitives.h:688
t_size get_size_total() const
Definition: alloc.h:159
void force_reset()
Definition: alloc.h:120
void move_from(t_self &other)
Definition: alloc.h:408
void set_size(t_size p_size)
Definition: alloc.h:62
T * __raw_malloc_t(t_size p_size)
Definition: alloc.h:31
void prealloc(t_size)
Definition: alloc.h:360
const t_item & operator[](t_size p_index) const
Definition: alloc.h:354
void set_size(t_size p_size)
Definition: alloc.h:422
void force_reset()
Definition: alloc.h:361
t_item * get_ptr()
Definition: alloc.h:116
t_item * get_ptr()
Definition: alloc.h:320
const t_self & operator=(const t_self &)
Definition: alloc.h:261
const t_item & operator[](t_size p_index) const
Definition: alloc.h:160
alloc_fast< t_item > t_self
Definition: alloc.h:337
void resize_content(t_size p_size)
Definition: alloc.h:265
__array_lite_helper_t< t_item > m_content
Definition: alloc.h:333
const t_item & operator[](t_size p_index) const
Definition: alloc.h:64
void move_from(t_self &other)
Definition: alloc.h:365
const t_item * get_ptr() const
Definition: alloc.h:401
t_item & operator[](t_size p_index)
Definition: alloc.h:317
void move_from(t_self &other)
Definition: alloc.h:505
t_item & operator[](t_size n)
Definition: alloc.h:445
int t_int
Definition: int_types.h:11
bool is_ptr_owned(const void *p_item) const
Definition: alloc.h:322
t_size get_size() const
Definition: alloc.h:495
t_item & operator[](t_size p_index)
Definition: alloc.h:483
void prealloc(t_size)
Definition: alloc.h:75
t_int safe_shift_left_t(t_int p_val, t_size p_shift=1)
Definition: alloc.h:52
void move_from(t_self &other)
Definition: alloc.h:452
t_type * __unsafe__in_place_constructor_array_copy_t(t_type *p_items, t_size p_count, const t_copy *p_copyfrom)
Definition: primitives.h:159
void __raw_free_t(T *p_block)
Definition: alloc.h:36
t_size m_size
Definition: alloc.h:134
bool is_ptr_owned(const void *p_item) const
Definition: alloc.h:403
t_alloc< t_item > m_variable
Definition: alloc.h:514
const t_item & operator[](t_size p_index) const
Definition: alloc.h:316
void move_from(t_self &other)
Definition: alloc.h:255
const t_item * get_ptr() const
Definition: alloc.h:252
const t_item & operator[](t_size n) const
Definition: alloc.h:444
void move_from(t_self &other)
Definition: alloc.h:328
t_size get_size() const
Definition: alloc.h:353
t_size calc_array_width(t_size p_width)
Definition: alloc.h:26
t_item * get_ptr()
Definition: alloc.h:358
alloc_dummy(const t_self &)
Definition: alloc.h:80
size_t t_size
Definition: int_types.h:48
t_size get_size() const
Definition: alloc.h:397
void set_size(t_size p_size)
Definition: alloc.h:233
t_item & operator[](t_size p_index)
Definition: alloc.h:399
t_size get_size() const
Definition: alloc.h:245
bool is_ptr_owned(const void *p_item) const
Definition: alloc.h:253
const t_item & operator[](t_size p_index) const
Definition: alloc.h:489
alloc_dummy< t_item > t_self
Definition: alloc.h:59
__array_fast_helper_t< t_item > t_self
Definition: alloc.h:139
void move_from(t_self &other)
Definition: alloc.h:169
t_size get_size() const
Definition: alloc.h:314
t_item & operator[](t_size p_index)
Definition: alloc.h:161
const t_self & operator=(const t_self &)
Definition: alloc.h:130
const t_item * get_ptr() const
Definition: alloc.h:357
void force_reset()
Definition: alloc.h:324
static void * raw_malloc(t_size p_size)
Definition: alloc.h:3
T * new_ptr_check_t(T *p_ptr)
Definition: primitives.h:663
const t_item * get_ptr() const
Definition: alloc.h:166
static bool raw_realloc_inplace(void *p_block, t_size p_size)
Definition: alloc.h:15
bool __raw_realloc_inplace_t(T *p_block, t_size p_size)
Definition: alloc.h:46
alloc_standard< t_item > t_self
Definition: alloc.h:309
const t_self & operator=(const t_self &)
Definition: alloc.h:331
alloc_fast_aggressive(const t_self &)
Definition: alloc.h:410
T * __raw_realloc_t(T *p_block, t_size p_size)
Definition: alloc.h:41
const t_self & operator=(const t_self &)
Definition: alloc.h:459
bool is_ptr_owned(const void *p_item) const
Definition: alloc.h:359
const t_item & operator[](t_size p_index) const
Definition: alloc.h:246
const t_self & operator=(const t_self &)
Definition: alloc.h:411
void prealloc(t_size p_size)
Definition: alloc.h:497
alloc_standard(const t_self &)
Definition: alloc.h:330
t_size get_size() const
Definition: alloc.h:439
t_item & operator[](t_size p_index)
Definition: alloc.h:111
bool is_ptr_owned(const void *p_item) const
Definition: alloc.h:496
t_item & operator[](t_size p_index)
Definition: alloc.h:65
const t_self & operator=(const t_self &)
Definition: alloc.h:176
const t_self & operator=(const t_self &)
Definition: alloc.h:368
void force_reset()
Definition: alloc.h:76
void __unsafe__in_place_constructor_t(t_type &p_item)
Definition: primitives.h:115
alloc< t_item > t_self
Definition: alloc.h:418
void resize_storage(t_size p_size)
Definition: alloc.h:281
const t_item & operator[](t_size p_index) const
Definition: alloc.h:110
t_type * __unsafe__in_place_constructor_array_t(t_type *p_items, t_size p_count)
Definition: primitives.h:130
alloc_fixed< p_width >::template alloc< t_item > m_fixed
Definition: alloc.h:513
t_size get_size() const
Definition: alloc.h:109
Simple inefficient fully portable allocator.
Definition: alloc.h:90
void set_size(t_size p_size)
Definition: alloc.h:341
void set_size(t_size p_size)
Definition: alloc.h:377
__array_lite_helper_t< t_item > t_self
Definition: alloc.h:228
t_item * get_ptr()
Definition: alloc.h:74
void memcpy_t(t_dst *p_dst, const t_src *p_src, t_size p_count)
Definition: primitives.h:611
void prealloc(t_size)
Definition: alloc.h:119
t_item * get_ptr()
Definition: alloc.h:441
void move_from(t_self &other)
Definition: alloc.h:124
const t_item * get_ptr() const
Definition: alloc.h:442
__array_fast_helper_t< t_item > m_data
Definition: alloc.h:369
alloc_simple< t_item > t_self
Definition: alloc.h:91
static void * raw_realloc(void *p_ptr, t_size p_size)
Definition: alloc.h:9
const t_item & operator[](t_size p_index) const
Definition: alloc.h:398
void set_size(t_size p_size)
Definition: alloc.h:473
t_item & operator[](t_size p_index)
Definition: alloc.h:247
bool is_ptr_owned(const void *p_item) const
Definition: alloc.h:112
bool is_ptr_owned(const void *p_item) const
Definition: alloc.h:446
t_item & operator[](t_size p_index)
Definition: alloc.h:355
__array_fast_helper_t(const t_self &)
Definition: alloc.h:177
t_item * m_data
Definition: alloc.h:133
const t_self & operator=(const t_self &)
Definition: alloc.h:511
void prealloc(t_size p_size)
Definition: alloc.h:323
bool is_pointer_in_range(const t_item *p_buffer, t_size p_buffer_size, const void *p_pointer)
Definition: alloc.h:84
alloc(const t_self &)
Definition: alloc.h:510
const t_self & operator=(const t_self &)
Definition: alloc.h:79
__array_lite_helper_t(const t_self &)
Definition: alloc.h:262
void resize_storage(t_size p_size)
Definition: alloc.h:196