alloc.cpp 446 B

1234567891011121314151617181920
  1. #include "alloc.h"
  2. #include <util/generic/singleton.h>
  3. #include <util/system/sys_alloc.h>
  4. using TBlock = TDefaultAllocator::TBlock;
  5. TBlock TDefaultAllocator::Allocate(size_t len) {
  6. TBlock ret = {y_allocate(len), len};
  7. return ret;
  8. }
  9. void TDefaultAllocator::Release(const TBlock& block) {
  10. y_deallocate(block.Data);
  11. }
  12. IAllocator* TDefaultAllocator::Instance() noexcept {
  13. return SingletonWithPriority<TDefaultAllocator, 0>();
  14. }