28 #ifndef YSL_INC_Adaptor_ynew_h_
29 #define YSL_INC_Adaptor_ynew_h_ 1
34 #include YFM_YSLib_Adaptor_Configuration
40 #include YFM_YBaseMacro
42 #ifdef YSL_USE_MEMORY_DEBUG
50 # include <ext/malloc_allocator.h>
70 operator delete(
void*,
const char*, int)
ynothrow;
72 operator delete[](
void*,
const char*, int)
ynothrow;
74 operator delete(
void*,
const std::nothrow_t&,
const char*, int)
ynothrow;
76 operator delete[](
void*,
const std::nothrow_t&,
const char*, int)
ynothrow;
95 template<
typename _type>
96 using MemoryListAllocator
98 = __gnu_cxx::malloc_allocator<_type>;
100 = std::allocator<_type>;
112 struct BlockInfo final
121 : size(s), file(f), line(l)
137 NewRecorder(
const char*
f,
int l, MemoryList& b = GetDebugMemoryList())
138 : blocks(b), file(f), line(l)
148 template<
typename _type>
150 operator->*(_type* p)
152 blocks.Register(p,
sizeof(_type), file, line);
157 using MapType = std::map<const void*, BlockInfo, std::less<const void*>,
158 MemoryListAllocator<std::pair<const void* const, BlockInfo>>>;
159 using ListType = std::list<std::pair<const void*, BlockInfo>,
160 MemoryListAllocator<std::pair<const void*, BlockInfo>>>;
163 ListType DuplicateDeletedBlocks;
166 MemoryList(
void(*)());
171 Register(
const void*,
std::size_t,
const char*,
int);
174 Unregister(
const void*,
const char*,
int);
178 Print(
const MapType::value_type&, std::FILE*);
181 PrintAll(std::FILE*);
184 PrintAllDuplicate(std::FILE*);
195 # define ynew YSLib::MemoryList::NewRecorder(__FILE__, __LINE__)->*new
196 # define ynew_nothrow new(std::nothrow, __FILE__, __LINE__)
197 # define ydelete(p) (GetDebugMemoryList().Unregister(p, __FILE__, \
199 # define ydelete_array(p) (GetDebugMemoryList().Unregister(p, __FILE__, \
206 # define ynew_nothrow new(std::nothrow)
207 # define ydelete delete
208 # define ydelete_array(p) (delete[] p)
#define DefGetter(_q, _t, _n,...)
map< VisualEvent, MappedType > MapType
映射表类型。
不可复制对象:禁止派生类调用默认原型的复制构造函数和复制赋值操作符。
#define YB_ALLOCATOR
指示修饰的是分配器,或返回分配器调用的函数或函数模板。
#define ynothrow
YSLib 无异常抛出保证:若支持 noexcept 关键字, 指定特定的 noexcept 异常规范。
GSStringTemplate< char >::basic_string string
#define ythrow(...)
YSLib 动态异常规范:根据是否使用异常规范宏指定或忽略动态异常规范。
#define yconstfn
指定编译时常量函数。