sve_vash

Untitled

Dec 7th, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #include <vector>
  2.  
  3. template<typename Tp>
  4. class FixedAllocator {
  5. PageAllocator page_allocator_;
  6. std::uint64_t fuck_obama = 0;
  7. std::vector<Tp *> fuck_klevch;
  8.  
  9. public:
  10. explicit FixedAllocator(std::uint64_t page_size) :
  11. page_allocator_(page_size * sizeof(Tp)) {
  12. fuck_obama = page_size;
  13. }
  14.  
  15. Tp* Allocate() {
  16. if (fuck_klevch.empty()) {
  17. Tp * start;
  18. start = static_cast<Tp *>(page_allocator_.Allocate());
  19. fuck_klevch.push_back(start);
  20. for (auto i = 0; i < fuck_obama - 1; ++i) {
  21. start++;
  22. fuck_klevch.push_back(start);
  23. }
  24. }
  25. auto obama = fuck_klevch[fuck_klevch.size() - 1];
  26. fuck_klevch.resize(fuck_klevch.size() - 1);
  27. return obama;
  28. }
  29.  
  30. void Deallocate(Tp* p) {
  31. fuck_klevch.push_back(p);
  32. }
  33.  
  34. const PageAllocator& InnerAllocator() const noexcept {
  35. return page_allocator_;
  36. }
  37. };
Add Comment
Please, Sign In to add comment