diff options
author | Andrey Khalyavin <halyavin@gmail.com> | 2022-02-10 16:46:29 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:29 +0300 |
commit | f773626848a7c7456803654292e716b83d69cc12 (patch) | |
tree | db052dfcf9134f492bdbb962cb6c16cea58e1ed3 /util/memory/smallobj.h | |
parent | f43ab775d197d300eb67bd4497632b909cd7c2a5 (diff) | |
download | ydb-f773626848a7c7456803654292e716b83d69cc12.tar.gz |
Restoring authorship annotation for Andrey Khalyavin <halyavin@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'util/memory/smallobj.h')
-rw-r--r-- | util/memory/smallobj.h | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/util/memory/smallobj.h b/util/memory/smallobj.h index 63de666bae..cb0490ab31 100644 --- a/util/memory/smallobj.h +++ b/util/memory/smallobj.h @@ -107,17 +107,17 @@ private: template <class T> class TObjectFromPool { public: - struct THeader { - void* Pool; - // Can't just use T because THeader must be standard layout type for offsetof to work. - alignas(T) char Obj[sizeof(T)]; - }; - using TPool = TSmallObjAllocator<THeader>; + struct THeader { + void* Pool; + // Can't just use T because THeader must be standard layout type for offsetof to work. + alignas(T) char Obj[sizeof(T)]; + }; + using TPool = TSmallObjAllocator<THeader>; inline void* operator new(size_t, TPool* pool) { - THeader* ret = pool->Allocate(); - ret->Pool = pool; - return &ret->Obj; + THeader* ret = pool->Allocate(); + ret->Pool = pool; + return &ret->Obj; } inline void operator delete(void* ptr, size_t) noexcept { @@ -134,8 +134,8 @@ public: private: static inline void DoDelete(void* ptr) noexcept { - static_assert(std::is_standard_layout<THeader>::value, "offsetof is only defined for standard layout types"); - THeader* header = (THeader*)((char*)ptr - offsetof(THeader, Obj)); - ((TPool*)header->Pool)->Release(header); + static_assert(std::is_standard_layout<THeader>::value, "offsetof is only defined for standard layout types"); + THeader* header = (THeader*)((char*)ptr - offsetof(THeader, Obj)); + ((TPool*)header->Pool)->Release(header); } }; |