diff options
author | Alexander Smirnov <alex@ydb.tech> | 2024-11-20 11:14:58 +0000 |
---|---|---|
committer | Alexander Smirnov <alex@ydb.tech> | 2024-11-20 11:14:58 +0000 |
commit | 31773f157bf8164364649b5f470f52dece0a4317 (patch) | |
tree | 33d0f7eef45303ab68cf08ab381ce5e5e36c5240 /util/system/filemap.h | |
parent | 2c7938962d8689e175574fc1e817c05049f27905 (diff) | |
parent | eff600952d5dfe17942f38f510a8ac2b203bb3a5 (diff) | |
download | ydb-31773f157bf8164364649b5f470f52dece0a4317.tar.gz |
Merge branch 'rightlib' into mergelibs-241120-1113
Diffstat (limited to 'util/system/filemap.h')
-rw-r--r-- | util/system/filemap.h | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/util/system/filemap.h b/util/system/filemap.h index 25a7911715..200774593b 100644 --- a/util/system/filemap.h +++ b/util/system/filemap.h @@ -233,8 +233,9 @@ public: return Size_; } const T& GetAt(size_t pos) const { - if (pos < Size_) + if (pos < Size_) { return Ptr_[pos]; + } return Dummy(); } void SetDummy(const T& n_Dummy) { @@ -334,8 +335,9 @@ public: TMappedArray(size_t siz = 0) : TMappedAllocation(0) { - if (siz) + if (siz) { Create(siz); + } } ~TMappedArray() { Destroy(); @@ -343,18 +345,21 @@ public: T* Create(size_t siz) { Y_ASSERT(MappedSize() == 0 && Ptr() == nullptr); T* arr = (T*)Alloc((sizeof(T) * siz)); - if (!arr) + if (!arr) { return nullptr; + } Y_ASSERT(MappedSize() == sizeof(T) * siz); - for (size_t n = 0; n < siz; n++) + for (size_t n = 0; n < siz; n++) { new (&arr[n]) T(); + } return arr; } void Destroy() { T* arr = (T*)Ptr(); if (arr) { - for (size_t n = 0; n < size(); n++) + for (size_t n = 0; n < size(); n++) { arr[n].~T(); + } Dealloc(); } } |