diff options
author | aosipenko <aosipenko@yandex-team.ru> | 2022-02-10 16:48:08 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:08 +0300 |
commit | 69e3c43df1c96bc2ac8946bf4dfb1f5fc438ff7f (patch) | |
tree | b222e5ac2e2e98872661c51ccceee5da0d291e13 /util/memory | |
parent | 948fd24d47d4b3b7815aaef1686aea00ef3f4288 (diff) | |
download | ydb-69e3c43df1c96bc2ac8946bf4dfb1f5fc438ff7f.tar.gz |
Restoring authorship annotation for <aosipenko@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/memory')
-rw-r--r-- | util/memory/pool.h | 30 | ||||
-rw-r--r-- | util/memory/pool_ut.cpp | 30 |
2 files changed, 30 insertions, 30 deletions
diff --git a/util/memory/pool.h b/util/memory/pool.h index da1b544c37..13c8b6b9ed 100644 --- a/util/memory/pool.h +++ b/util/memory/pool.h @@ -159,7 +159,7 @@ public: inline T* Allocate() { return (T*)this->Allocate(sizeof(T), alignof(T)); } - + template <typename T> inline T* Allocate(size_t align) { return (T*)this->Allocate(sizeof(T), Max(align, alignof(T))); @@ -175,20 +175,20 @@ public: return (T*)this->Allocate(sizeof(T) * count, Max(align, alignof(T))); } - template <typename T> - inline T* AllocateZeroArray(size_t count) { - T* ptr = AllocateArray<T>(count); - memset(ptr, 0, count * sizeof(T)); - return ptr; - } - - template <typename T> - inline T* AllocateZeroArray(size_t count, size_t align) { - T* ptr = AllocateArray<T>(count, align); - memset(ptr, 0, count * sizeof(T)); - return ptr; - } - + template <typename T> + inline T* AllocateZeroArray(size_t count) { + T* ptr = AllocateArray<T>(count); + memset(ptr, 0, count * sizeof(T)); + return ptr; + } + + template <typename T> + inline T* AllocateZeroArray(size_t count, size_t align) { + T* ptr = AllocateArray<T>(count, align); + memset(ptr, 0, count * sizeof(T)); + return ptr; + } + template <typename T, typename... Args> inline T* New(Args&&... args) { return new (Allocate<T>()) T(std::forward<Args>(args)...); diff --git a/util/memory/pool_ut.cpp b/util/memory/pool_ut.cpp index 3268ed841f..1158a8ca42 100644 --- a/util/memory/pool_ut.cpp +++ b/util/memory/pool_ut.cpp @@ -80,7 +80,7 @@ class TMemPoolTest: public TTestBase { UNIT_TEST_SUITE(TMemPoolTest); UNIT_TEST(TestMemPool) UNIT_TEST(TestAlign) - UNIT_TEST(TestZeroArray) + UNIT_TEST(TestZeroArray) UNIT_TEST(TestLargeStartingAlign) UNIT_TEST(TestMoveAlloc) UNIT_TEST(TestRoundUpToNextPowerOfTwoOption) @@ -196,22 +196,22 @@ private: UNIT_ASSERT_VALUES_EQUAL(reinterpret_cast<uintptr_t>(aligned256) & 255, 0); UNIT_ASSERT_VALUES_EQUAL(reinterpret_cast<uintptr_t>(aligned1024) & 1023, 0); } - - void TestZeroArray() { - TMemoryPool pool(1); - size_t size = 10; - i32* intArray = pool.AllocateZeroArray<i32>(size); - for (size_t i = 0; i < size; ++i) { - UNIT_ASSERT(intArray[i] == 0); - } - + + void TestZeroArray() { + TMemoryPool pool(1); + size_t size = 10; + i32* intArray = pool.AllocateZeroArray<i32>(size); + for (size_t i = 0; i < size; ++i) { + UNIT_ASSERT(intArray[i] == 0); + } + size_t align = 256; - ui8* byteArray = pool.AllocateZeroArray<ui8>(size, align); - UNIT_ASSERT(size_t(byteArray) % align == 0); - for (size_t i = 0; i < size; ++i) { - UNIT_ASSERT(byteArray[i] == 0); + ui8* byteArray = pool.AllocateZeroArray<ui8>(size, align); + UNIT_ASSERT(size_t(byteArray) % align == 0); + for (size_t i = 0; i < size; ++i) { + UNIT_ASSERT(byteArray[i] == 0); } - } + } void TestLargeStartingAlign() { TMemoryPool pool(1); |