31 #include "../my_config.h" 55 #ifdef LIBDAR_SPECIAL_ALLOC 75 const on_pool & operator = (
const on_pool & ref) {
return *
this; };
84 void *
operator new(
size_t n_byte) {
void *ret = alloc(n_byte,
nullptr);
if(ret ==
nullptr)
throw std::bad_alloc();
return ret; };
90 void *
operator new(
size_t n_byte,
const std::nothrow_t & nothrow_value) {
return alloc(n_byte,
nullptr); };
96 void *
operator new[](
size_t n_byte) {
void *ret = alloc(n_byte,
nullptr);
if(ret ==
nullptr)
throw std::bad_alloc();
return ret; };
102 void *
operator new[](
size_t n_byte,
const std::nothrow_t & nothrow_value) {
return alloc(n_byte,
nullptr); };
108 void *
operator new(
size_t n_byte, memory_pool *p) {
return alloc(n_byte, p); };
115 void *
operator new[] (
size_t n_byte, memory_pool *p) {
return alloc(n_byte, p); };
119 void operator delete(
void *ptr, memory_pool *p) { dealloc(ptr); };
123 void operator delete[](
void *ptr, memory_pool *p) { dealloc(ptr); };
127 void operator delete(
void *ptr) { dealloc(ptr); };
131 void operator delete[](
void *ptr) { dealloc(ptr); };
141 #ifdef LIBDAR_SPECIAL_ALLOC 142 memory_pool *
get_pool()
const {
return dynamic ? (((pool_ptr *)
this) - 1)->reserve :
nullptr; };
147 template <
class T>
void meta_new(T * & ptr,
size_t num)
149 #ifdef LIBDAR_SPECIAL_ALLOC 150 size_t byte = num *
sizeof(T);
155 ptr = (T *)
new (std::nothrow)
char [byte];
157 ptr =
new (std::nothrow) T[num];
163 template <
class T>
void meta_delete(T * ptr)
165 #ifdef LIBDAR_SPECIAL_ALLOC 169 delete [] (
char *)(ptr);
176 #ifdef LIBDAR_SPECIAL_ALLOC 184 memory_pool *reserve;
195 void dynamic_init()
const {
const_cast<on_pool *
>(
this)->dynamic = (alloc_not_constructed ==
this); alloc_not_constructed =
nullptr; };
203 static void *alloc(
size_t size, memory_pool *p);
209 static void dealloc(
void *ptr);
211 #ifdef LIBDAR_SPECIAL_ALLOC 213 static on_pool *alloc_not_constructed;
220 thread_local
static on_pool * alloc_not_constructed;
are defined here basic integer types that tend to be portable
class memory_pool allocates and recycles blocks of memory for better performances it is expected to b...
memory_pool * get_pool() const
thin adaptation layer to Cygwin specifities
exception used to signal a bug. A bug is triggered when reaching some code that should never be reach...
this is the base class of object that can provide dynamically allocated memory blocks ...
libdar namespace encapsulate all libdar symbols