| 43 | context_memory& operator=(const context_memory&) = delete; |
| 44 | |
| 45 | void* allocate(std::size_t size, std::size_t align) |
| 46 | { |
| 47 | // Since this program is single-threaded there is no need to perform any |
| 48 | // synchronisation when modifying next_allocation_. Use an atomic or other |
| 49 | // form of synchronisation when using an exeution context from multiple |
| 50 | // threads. |
| 51 | std::size_t space = size + align; |
| 52 | if (next_allocation_ + space < preallocated_) |
| 53 | { |
| 54 | void* ptr = storage_ + next_allocation_; |
| 55 | next_allocation_ += space; |
| 56 | return std::align(align, size, ptr, space); |
| 57 | } |
| 58 | else |
| 59 | { |
| 60 | return ::operator new(size); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | void deallocate(void* ptr) |
| 65 | { |
no test coverage detected