Ilya_konstantinov

Untitled

Mar 23rd, 2026
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | Source Code | 0 0
  1. #include "simple-allocator.hpp"
  2.  
  3. #include <syscalls.hpp>
  4.  
  5. #include <cstddef>
  6. #include <type_traits>
  7.  
  8. struct AllocatorState {
  9.     static constexpr size_t kBlockSize = 16;
  10.     static constexpr size_t kPageSize = 1 << 12;
  11.  
  12.     void* Allocate16() {
  13.         return nullptr;  // TODO: remove before flight.
  14.     }
  15.  
  16.     void Deallocate(void* ptr) {
  17.         (void)ptr;  // TODO: remove before flight.
  18.     }
  19.  
  20.     // TODO: your code here.
  21. };
  22.  
  23. static AllocatorState allocator_state_;
  24. static_assert(std::is_trivially_constructible_v<AllocatorState>);
  25.  
  26. void* Allocate16() {
  27.     return allocator_state_.Allocate16();
  28. }
  29.  
  30. void Deallocate16(void* ptr) {
  31.     allocator_state_.Deallocate(ptr);
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment