diff options
author | vvvv <[email protected]> | 2025-10-06 11:26:09 +0300 |
---|---|---|
committer | vvvv <[email protected]> | 2025-10-06 11:53:26 +0300 |
commit | 60f45e69a4d7dbc6131208e16c45faf35aa5a985 (patch) | |
tree | 4daa45b52c295a178c7620e4c93921465fcf7950 /yql/essentials/utils/limiting_allocator.cpp | |
parent | 1bded1a65a7e6e9171418f3e1c691d390125b64e (diff) |
YQL-20086 utils
init
commit_hash:54feccd520ebd0ab23612bc0cb830914dff9d0e8
Diffstat (limited to 'yql/essentials/utils/limiting_allocator.cpp')
-rw-r--r-- | yql/essentials/utils/limiting_allocator.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/yql/essentials/utils/limiting_allocator.cpp b/yql/essentials/utils/limiting_allocator.cpp index 0ff84f90378..e25ec99a427 100644 --- a/yql/essentials/utils/limiting_allocator.cpp +++ b/yql/essentials/utils/limiting_allocator.cpp @@ -4,9 +4,12 @@ #include <util/generic/yexception.h> namespace { -class TLimitingAllocator : public IAllocator { +class TLimitingAllocator: public IAllocator { public: - TLimitingAllocator(size_t limit, IAllocator* allocator) : Alloc_(allocator), Limit_(limit) {}; + TLimitingAllocator(size_t limit, IAllocator* allocator) + : Alloc_(allocator) + , Limit_(limit) + {}; TBlock Allocate(size_t len) override final { if (Allocated_ + len > Limit_) { throw std::runtime_error("Out of memory"); @@ -26,10 +29,10 @@ private: size_t Allocated_ = 0; const size_t Limit_; }; -} +} // namespace namespace NYql { std::unique_ptr<IAllocator> MakeLimitingAllocator(size_t limit, IAllocator* underlying) { return std::make_unique<TLimitingAllocator>(limit, underlying); } -} +} // namespace NYql |