aboutsummaryrefslogtreecommitdiffstats
path: root/util/memory
diff options
context:
space:
mode:
authoryazevnul <yazevnul@yandex-team.ru>2022-02-10 16:46:48 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:48 +0300
commit9abfb1a53b7f7b791444d1378e645d8fad9b06ed (patch)
tree49e222ea1c5804306084bb3ae065bb702625360f /util/memory
parent8cbc307de0221f84c80c42dcbe07d40727537e2c (diff)
downloadydb-9abfb1a53b7f7b791444d1378e645d8fad9b06ed.tar.gz
Restoring authorship annotation for <yazevnul@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/memory')
-rw-r--r--util/memory/blob.cpp12
-rw-r--r--util/memory/blob.h6
-rw-r--r--util/memory/blob_ut.cpp2
-rw-r--r--util/memory/pool.h6
-rw-r--r--util/memory/pool_ut.cpp2
-rw-r--r--util/memory/segmented_string_pool.h40
-rw-r--r--util/memory/segpool_alloc.h16
-rw-r--r--util/memory/smallobj.h2
-rw-r--r--util/memory/smallobj_ut.cpp14
-rw-r--r--util/memory/tempbuf.cpp4
-rw-r--r--util/memory/tempbuf.h4
11 files changed, 54 insertions, 54 deletions
diff --git a/util/memory/blob.cpp b/util/memory/blob.cpp
index e9936c2bcb..91da5cadca 100644
--- a/util/memory/blob.cpp
+++ b/util/memory/blob.cpp
@@ -4,7 +4,7 @@
#include <util/system/yassert.h>
#include <util/system/filemap.h>
#include <util/system/mlock.h>
-#include <util/stream/buffer.h>
+#include <util/stream/buffer.h>
#include <util/generic/ptr.h>
#include <util/generic/string.h>
#include <util/generic/buffer.h>
@@ -174,7 +174,7 @@ static inline TBlob CopyConstruct(const void* data, size_t len) {
using Base = TDynamicBlobBase<TCounter>;
THolder<Base> base(new (len) Base);
- Y_ASSERT(base->Length() == len);
+ Y_ASSERT(base->Length() == len);
memcpy(base->Data(), data, len);
@@ -305,7 +305,7 @@ static inline TBlob ReadFromFile(const TFile& file, ui64 offset, size_t length)
using TBase = TDynamicBlobBase<TCounter>;
THolder<TBase> base(new (length) TBase);
- Y_ASSERT(base->Length() == length);
+ Y_ASSERT(base->Length() == length);
file.Pload(base->Data(), length, offset);
@@ -362,7 +362,7 @@ static inline TBlob ConstructFromBuffer(TBuffer& in) {
}
template <class TCounter>
-static inline TBlob ConstructFromStream(IInputStream& in) {
+static inline TBlob ConstructFromStream(IInputStream& in) {
TBuffer buf;
{
@@ -374,11 +374,11 @@ static inline TBlob ConstructFromStream(IInputStream& in) {
return ConstructFromBuffer<TCounter>(buf);
}
-TBlob TBlob::FromStreamSingleThreaded(IInputStream& in) {
+TBlob TBlob::FromStreamSingleThreaded(IInputStream& in) {
return ConstructFromStream<TSimpleCounter>(in);
}
-TBlob TBlob::FromStream(IInputStream& in) {
+TBlob TBlob::FromStream(IInputStream& in) {
return ConstructFromStream<TAtomicCounter>(in);
}
diff --git a/util/memory/blob.h b/util/memory/blob.h
index b5a610bce8..20c02a68df 100644
--- a/util/memory/blob.h
+++ b/util/memory/blob.h
@@ -6,7 +6,7 @@
#include <util/system/defaults.h>
class TMemoryMap;
-class IInputStream;
+class IInputStream;
class TFile;
class TBuffer;
@@ -281,10 +281,10 @@ public:
static TBlob FromFileContent(const TFile& file, ui64 offset, size_t length);
/// Creates a blob from the stream content with a single-threaded (non atomic) refcounter.
- static TBlob FromStreamSingleThreaded(IInputStream& in);
+ static TBlob FromStreamSingleThreaded(IInputStream& in);
/// Creates a blob from the stream content with a multi-threaded (atomic) refcounter.
- static TBlob FromStream(IInputStream& in);
+ static TBlob FromStream(IInputStream& in);
/// Creates a blob with a single-threaded (non atomic) refcounter. No memory allocation, no content copy.
/// @details The input object becomes empty.
diff --git a/util/memory/blob_ut.cpp b/util/memory/blob_ut.cpp
index d5b14b8672..023f9a0487 100644
--- a/util/memory/blob_ut.cpp
+++ b/util/memory/blob_ut.cpp
@@ -4,7 +4,7 @@
#include <util/system/tempfile.h>
#include <util/folder/path.h>
-#include <util/stream/output.h>
+#include <util/stream/output.h>
#include <util/stream/file.h>
#include <util/generic/buffer.h>
#include <util/generic/array_ref.h>
diff --git a/util/memory/pool.h b/util/memory/pool.h
index 0de5467701..13c8b6b9ed 100644
--- a/util/memory/pool.h
+++ b/util/memory/pool.h
@@ -33,7 +33,7 @@ private:
: Cur_((char*)(this + 1))
, Left_(len)
{
- Y_ASSERT((((size_t)Cur_) % PLATFORM_DATA_ALIGN) == 0);
+ Y_ASSERT((((size_t)Cur_) % PLATFORM_DATA_ALIGN) == 0);
}
inline void* Allocate(size_t len) noexcept {
@@ -46,7 +46,7 @@ private:
return ret;
}
- return nullptr;
+ return nullptr;
}
inline void* Allocate(size_t len, size_t align) noexcept {
@@ -57,7 +57,7 @@ private:
return static_cast<char*>(ret) + pad;
}
- return nullptr;
+ return nullptr;
}
inline size_t BlockLength() const noexcept {
diff --git a/util/memory/pool_ut.cpp b/util/memory/pool_ut.cpp
index dd79864f72..1158a8ca42 100644
--- a/util/memory/pool_ut.cpp
+++ b/util/memory/pool_ut.cpp
@@ -2,7 +2,7 @@
#include <library/cpp/testing/unittest/registar.h>
-#include <util/stream/output.h>
+#include <util/stream/output.h>
class TCheckedAllocator: public TDefaultAllocator {
public:
diff --git a/util/memory/segmented_string_pool.h b/util/memory/segmented_string_pool.h
index ecc3ca3c1a..a40aa408f5 100644
--- a/util/memory/segmented_string_pool.h
+++ b/util/memory/segmented_string_pool.h
@@ -23,7 +23,7 @@ protected:
size_t _size; // size of allocated chunk in sizeof(T)-units
size_t freepos; // offset to free chunk's memory in bytes
seg_inf()
- : data(nullptr)
+ : data(nullptr)
, _size(0)
, freepos(0)
{
@@ -46,23 +46,23 @@ protected:
const char* Name; // for debug memory usage
protected:
void check_capacity(size_t len) {
- if (Y_UNLIKELY(!last_free || len > last_free)) {
+ if (Y_UNLIKELY(!last_free || len > last_free)) {
if (curseg != segs.end() && curseg->freepos > 0)
++curseg;
last_free = (len > segment_size ? len : segment_size);
if (curseg == segs.end() || curseg->_size < last_free) {
segs.push_back(seg_inf(seg_allocator.allocate(last_free), last_free));
- if (Y_UNLIKELY(Name))
+ if (Y_UNLIKELY(Name))
printf("Pool \"%s\" was increased by %" PRISZT " bytes to %" PRISZT " Mb.\n", Name, last_free * sizeof(T), capacity() / 0x100000);
curseg = segs.end() - 1;
}
- Y_ASSERT(curseg->freepos == 0);
- Y_ASSERT(curseg->_size >= last_free);
+ Y_ASSERT(curseg->freepos == 0);
+ Y_ASSERT(curseg->_size >= last_free);
}
}
public:
- explicit segmented_pool(size_t segsz, const char* name = nullptr)
+ explicit segmented_pool(size_t segsz, const char* name = nullptr)
: segment_size(segsz)
, last_free(0)
, last_ins_size(0)
@@ -131,18 +131,18 @@ public:
last_ins_size = 0;
}
void undo_last_append() {
- Y_ASSERT(curseg != segs.end()); // do not use before append()
+ Y_ASSERT(curseg != segs.end()); // do not use before append()
if (last_ins_size) {
- Y_ASSERT(last_ins_size <= curseg->freepos);
+ Y_ASSERT(last_ins_size <= curseg->freepos);
curseg->freepos -= last_ins_size;
last_free += last_ins_size / sizeof(T);
last_ins_size = 0;
}
}
void alloc_first_seg() {
- Y_ASSERT(capacity() == 0);
+ Y_ASSERT(capacity() == 0);
check_capacity(segment_size);
- Y_ASSERT(capacity() == segment_size * sizeof(T));
+ Y_ASSERT(capacity() == segment_size * sizeof(T));
}
};
@@ -151,27 +151,27 @@ private:
using _Base = segmented_pool<char>;
public:
- segmented_string_pool()
- : segmented_string_pool(1024 * 1024)
- {
- }
-
- explicit segmented_string_pool(size_t segsz)
+ segmented_string_pool()
+ : segmented_string_pool(1024 * 1024)
+ {
+ }
+
+ explicit segmented_string_pool(size_t segsz)
: _Base(segsz)
{
}
char* append(const char* src) {
- Y_ASSERT(src);
+ Y_ASSERT(src);
return _Base::append(src, strlen(src) + 1);
}
char* append(const char* src, size_t len) {
- char* rv = _Base::append(nullptr, len + 1);
+ char* rv = _Base::append(nullptr, len + 1);
if (src)
memcpy(rv, src, len);
rv[len] = 0;
return rv;
}
- char* Append(const TStringBuf s) {
+ char* Append(const TStringBuf s) {
return append(s.data(), s.size());
}
void align_4() {
@@ -180,7 +180,7 @@ public:
curseg->freepos = t;
}
char* Allocate(size_t len) {
- return append(nullptr, len);
+ return append(nullptr, len);
}
};
diff --git a/util/memory/segpool_alloc.h b/util/memory/segpool_alloc.h
index ce23fd6392..1a83b7a543 100644
--- a/util/memory/segpool_alloc.h
+++ b/util/memory/segpool_alloc.h
@@ -45,40 +45,40 @@ struct segpool_alloc {
segpool_alloc()
: pool(nullptr)
{
- Y_IF_DEBUG(pool_count = malloc_count = pool_free_count = malloc_free_count = 0);
+ Y_IF_DEBUG(pool_count = malloc_count = pool_free_count = malloc_free_count = 0);
}
segpool_alloc(pool_type* p)
: pool(p)
{
- Y_IF_DEBUG(pool_count = malloc_count = pool_free_count = malloc_free_count = 0);
+ Y_IF_DEBUG(pool_count = malloc_count = pool_free_count = malloc_free_count = 0);
}
segpool_alloc(const segpool_alloc& a)
: pool(a.pool)
{
- Y_IF_DEBUG(pool_count = malloc_count = pool_free_count = malloc_free_count = 0);
+ Y_IF_DEBUG(pool_count = malloc_count = pool_free_count = malloc_free_count = 0);
}
template <class _Tp1>
segpool_alloc(const segpool_alloc<_Tp1>& a)
: pool(a.pool)
{
- Y_IF_DEBUG(pool_count = malloc_count = pool_free_count = malloc_free_count = 0);
+ Y_IF_DEBUG(pool_count = malloc_count = pool_free_count = malloc_free_count = 0);
}
_Tp* allocate(size_t __n) {
if (!pool) {
_Tp* data = (_Tp*)malloc(__n * sizeof(_Tp));
- Y_IF_DEBUG(if (data) malloc_count++);
+ Y_IF_DEBUG(if (data) malloc_count++);
return data;
}
_Tp* data = (_Tp*)pool->append(nullptr, __n * sizeof(_Tp));
- Y_IF_DEBUG(pool_count++);
+ Y_IF_DEBUG(pool_count++);
return data;
}
void deallocate(pointer __p, size_t /*__n*/) {
if (!pool) {
- Y_IF_DEBUG(malloc_free_count++);
+ Y_IF_DEBUG(malloc_free_count++);
free(__p);
} else {
- Y_IF_DEBUG(pool_free_count++);
+ Y_IF_DEBUG(pool_free_count++);
;
}
}
diff --git a/util/memory/smallobj.h b/util/memory/smallobj.h
index 6fbfa83665..63de666bae 100644
--- a/util/memory/smallobj.h
+++ b/util/memory/smallobj.h
@@ -55,7 +55,7 @@ public:
}
inline void* Allocate() {
- if (Y_UNLIKELY(Free_.Empty())) {
+ if (Y_UNLIKELY(Free_.Empty())) {
return Pool_.Allocate(AllocSize_, AlignSize_);
}
diff --git a/util/memory/smallobj_ut.cpp b/util/memory/smallobj_ut.cpp
index 8730e97e22..86003d1d53 100644
--- a/util/memory/smallobj_ut.cpp
+++ b/util/memory/smallobj_ut.cpp
@@ -17,7 +17,7 @@ class TSmallObjAllocTest: public TTestBase {
}
};
- struct TClass64: public TObjectFromPool<TClass64> {
+ struct TClass64: public TObjectFromPool<TClass64> {
alignas(64) ui64 Data = 0;
};
@@ -30,10 +30,10 @@ class TSmallObjAllocTest: public TTestBase {
private:
void TestAlign() {
TClass64::TPool pool(TDefaultAllocator::Instance());
- TClass64* f1 = new (&pool) TClass64;
- TClass64* f2 = new (&pool) TClass64;
- TClass64* f3 = new (&pool) TClass64;
- TClass64* f4 = new (&pool) TClass64;
+ TClass64* f1 = new (&pool) TClass64;
+ TClass64* f2 = new (&pool) TClass64;
+ TClass64* f3 = new (&pool) TClass64;
+ TClass64* f4 = new (&pool) TClass64;
UNIT_ASSERT_VALUES_EQUAL(64u, alignof(TClass64));
UNIT_ASSERT_VALUES_EQUAL((size_t)0, (size_t)(f1) & (alignof(TClass64) - 1));
UNIT_ASSERT_VALUES_EQUAL((size_t)0, (size_t)(f2) & (alignof(TClass64) - 1));
@@ -70,8 +70,8 @@ private:
alloced.insert(c);
}
- for (auto it : alloced) {
- delete it;
+ for (auto it : alloced) {
+ delete it;
}
for (size_t i = 0; i < 10000; ++i) {
diff --git a/util/memory/tempbuf.cpp b/util/memory/tempbuf.cpp
index 6e87d94c49..09a2d0f140 100644
--- a/util/memory/tempbuf.cpp
+++ b/util/memory/tempbuf.cpp
@@ -54,12 +54,12 @@ public:
}
void SetPos(size_t off) {
- Y_ASSERT(off <= Size());
+ Y_ASSERT(off <= Size());
Offset_ = off;
}
inline void Proceed(size_t off) {
- Y_ASSERT(off <= Left());
+ Y_ASSERT(off <= Left());
Offset_ += off;
}
diff --git a/util/memory/tempbuf.h b/util/memory/tempbuf.h
index 2cc3ebe867..334670eb1e 100644
--- a/util/memory/tempbuf.h
+++ b/util/memory/tempbuf.h
@@ -59,10 +59,10 @@ private:
static const T* TypedPointer(const char* pointer) noexcept {
return reinterpret_cast<const T*>(pointer);
}
- static constexpr size_t RawSize(const size_t size) noexcept {
+ static constexpr size_t RawSize(const size_t size) noexcept {
return size * sizeof(T);
}
- static constexpr size_t TypedSize(const size_t size) noexcept {
+ static constexpr size_t TypedSize(const size_t size) noexcept {
return size / sizeof(T);
}