1 #include "utils/BumpAllocator.h"
3 #include <utils/Assert.h>
8 buffers_.emplace_back(size, std::malloc(size));
9 cur_buf_ = buffers_.begin();
10 alloc_top_ = cur_buf_->buf;
16 "attempt to allocate when CustomBufferResource is invalid");
19 if(bytes == 0) bytes = 1;
22 void* p = std::align(alignment, bytes, alloc_top_, avail_);
27 if(std::next(cur_buf_) == buffers_.end()) {
28 size_t new_size = cur_buf_->size * growth_factor;
29 buffers_.emplace_back(new_size, std::malloc(new_size));
30 cur_buf_ = std::prev(buffers_.end());
34 alloc_top_ = cur_buf_->buf;
35 avail_ = cur_buf_->size;
40 alloc_top_ =
static_cast<
char*>(alloc_top_) + bytes;
49 for(
auto& buf : buffers_) {
50 std::memset(buf.buf, 0, buf.size);
55 for(
auto& buf : buffers_) {