diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:15 +0300 |
commit | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch) | |
tree | da2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /util/generic/buffer.cpp | |
parent | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff) | |
download | ydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'util/generic/buffer.cpp')
-rw-r--r-- | util/generic/buffer.cpp | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/util/generic/buffer.cpp b/util/generic/buffer.cpp index b92697e1d0..6289bdb3bd 100644 --- a/util/generic/buffer.cpp +++ b/util/generic/buffer.cpp @@ -2,26 +2,26 @@ #include "mem_copy.h" #include "string.h" #include "ymath.h" - -#include <util/system/sys_alloc.h> + +#include <util/system/sys_alloc.h> #include <util/system/sanitizers.h> - -TBuffer::TBuffer(size_t len) + +TBuffer::TBuffer(size_t len) : Data_(nullptr) - , Len_(0) - , Pos_(0) -{ - Reserve(len); -} - -TBuffer::TBuffer(TBuffer&& b) noexcept - : Data_(nullptr) - , Len_(0) - , Pos_(0) -{ - Swap(b); -} - + , Len_(0) + , Pos_(0) +{ + Reserve(len); +} + +TBuffer::TBuffer(TBuffer&& b) noexcept + : Data_(nullptr) + , Len_(0) + , Pos_(0) +{ + Swap(b); +} + TBuffer::TBuffer(const char* buf, size_t len) : Data_(nullptr) , Len_(0) @@ -30,7 +30,7 @@ TBuffer::TBuffer(const char* buf, size_t len) Append(buf, len); } -TBuffer& TBuffer::operator=(TBuffer&& b) noexcept { +TBuffer& TBuffer::operator=(TBuffer&& b) noexcept { y_deallocate(Data_); Data_ = b.Data_; @@ -72,28 +72,28 @@ void TBuffer::Fill(char ch, size_t len) { Y_ASSERT(Pos_ <= Len_); } -void TBuffer::DoReserve(size_t realLen) { +void TBuffer::DoReserve(size_t realLen) { // FastClp2<T>(x) returns 0 on x from [Max<T>/2 + 2, Max<T>] const size_t len = Max<size_t>(FastClp2(realLen), realLen); - + Y_ASSERT(realLen > Len_); Y_ASSERT(len >= realLen); - + Realloc(len); } void TBuffer::Realloc(size_t len) { Y_ASSERT(Pos_ <= len); - Data_ = (char*)y_reallocate(Data_, len); - Len_ = len; -} - + Data_ = (char*)y_reallocate(Data_, len); + Len_ = len; +} + TBuffer::~TBuffer() { - y_deallocate(Data_); -} - + y_deallocate(Data_); +} + void TBuffer::AsString(TString& s) { - s.assign(Data(), Size()); - Clear(); -} + s.assign(Data(), Size()); + Clear(); +} |