28 #ifndef YSL_INC_ADAPTOR_YNEW_H_
29 #define YSL_INC_ADAPTOR_YNEW_H_ 1
38 #include "../Core/ybasemac.h"
40 #ifdef YSL_USE_MEMORY_DEBUG
47 #include <ext/malloc_allocator.h>
58 operator new(std::size_t,
const char*, int)
ythrow(std::bad_alloc);
60 operator new[](std::size_t,
const char*, int)
ythrow(std::bad_alloc);
62 operator new(std::size_t,
const std::nothrow_t&,
const char*, int)
ynothrow;
64 operator new[](std::size_t,
const std::nothrow_t&,
const char*, int)
ynothrow;
66 operator delete(
void*,
const char*, int)
ynothrow;
68 operator delete[](
void*,
const char*, int)
ynothrow;
70 operator delete(
void*,
const std::nothrow_t&,
const char*, int)
ynothrow;
72 operator delete[](
void*,
const std::nothrow_t&,
const char*, int)
ynothrow;
106 : size(s), file(f), line(l)
123 : blocks(b), file(f), line(l)
133 template<
typename _type>
135 operator->*(_type* p)
137 blocks.Register(p,
sizeof(_type), file, line);
142 typedef std::map<const void*, BlockInfo, std::less<const void*>,
143 __gnu_cxx::malloc_allocator<std::pair<const void* const, BlockInfo>> >
145 typedef std::list<std::pair<const void*, BlockInfo>,
146 __gnu_cxx::malloc_allocator<std::pair<const void*, BlockInfo>> >
158 Register(
const void*, std::size_t,
const char*,
int);
161 Unregister(
const void*,
const char*,
int);
165 Print(
const MapType::value_type&, std::FILE*);
168 PrintAll(std::FILE*);
171 PrintAllDuplicate(std::FILE*);
183 # define ynew YSLib::MemoryList::NewRecorder(__FILE__, __LINE__)->*new
184 # define ynew_nothrow new(std::nothrow, __FILE__, __LINE__)
185 # define ydelete(p) (GetDebugMemoryList().Unregister(p, __FILE__, \
187 # define ydelete_array(p) (GetDebugMemoryList().Unregister(p, __FILE__, \
194 # define ynew_nothrow new(std::nothrow)
195 # define ydelete delete
196 # define ydelete_array(p) (delete[] p)