Lugdunum  0.1.0
Stack.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  Stack(const Stack&) = delete;
22  Stack(Stack&&) = default;
23 
24  Stack& operator=(const Stack&) = delete;
25  Stack& operator=(Stack&&) = default;
26 
27  ~Stack() = default;
28 
29  void* allocate(size_t size, size_t alignment, size_t offset);
30  void free(void* ptr);
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: Stack.hpp:16
lug::System::Memory::Area::IArea *const _area
Definition: Stack.hpp:41