Lugdunum  0.1.0
Linear.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cstddef>
4 #include <lug/System/Export.hpp>
6 
7 namespace lug {
8 namespace System {
9 namespace Memory {
10 namespace Allocator {
11 
13 public:
14  struct Mark {
15  void* current;
17  };
18 
19 public:
21  Linear(const Linear&) = delete;
22  Linear(Linear&&) = default;
23 
24  Linear& operator=(const Linear&) = delete;
25  Linear& operator=(Linear&&) = default;
26 
27  ~Linear() = default;
28 
29  void* allocate(size_t size, size_t alignment, size_t offset);
30  void free(void* ptr) const;
31  void reset();
32 
33  // Dangerous operations
34  // Don't free previously allocated pointer after this mark !
35  Mark getMark() const;
36  void rewind(const Mark& mark);
37 
38  size_t getSize(void* ptr) const;
39 
40 private:
42 
43  void* _current{nullptr};
44  lug::System::Memory::Area::Page* _currentPage{nullptr};
45  lug::System::Memory::Area::Page* _firstPage{nullptr};
46 };
47 
48 } // Allocator
49 } // Memory
50 } // System
51 } // lug
#define LUG_SYSTEM_API
Definition: Export.hpp:11
lug::System::Memory::Area::Page * currentPage
Definition: Linear.hpp:16
lug::System::Memory::Area::IArea *const _area
Definition: Linear.hpp:41