Austin Schuh | 40485ed | 2019-10-26 21:51:44 -0700 | [diff] [blame] | 1 | #include "aos/flatbuffers.h" |
| 2 | |
| 3 | #include "glog/logging.h" |
| 4 | |
| 5 | namespace aos { |
| 6 | |
Brian Silverman | 1715d47 | 2020-08-12 22:54:15 -0700 | [diff] [blame^] | 7 | uint8_t *FixedAllocatorBase::allocate(size_t allocated_size) { |
Austin Schuh | 40485ed | 2019-10-26 21:51:44 -0700 | [diff] [blame] | 8 | if (is_allocated_) { |
Austin Schuh | 3da7b27 | 2020-01-06 18:41:40 -0800 | [diff] [blame] | 9 | LOG(FATAL) << "Can't allocate more memory with a fixed size allocator. " |
| 10 | "Increase the memory reserved."; |
Austin Schuh | 40485ed | 2019-10-26 21:51:44 -0700 | [diff] [blame] | 11 | } |
Brian Silverman | 1715d47 | 2020-08-12 22:54:15 -0700 | [diff] [blame^] | 12 | CHECK_LE(allocated_size, size()); |
Austin Schuh | 40485ed | 2019-10-26 21:51:44 -0700 | [diff] [blame] | 13 | |
| 14 | is_allocated_ = true; |
| 15 | return data(); |
| 16 | } |
| 17 | |
| 18 | uint8_t *FixedAllocatorBase::reallocate_downward(uint8_t *, size_t, size_t, |
| 19 | size_t, size_t) { |
Austin Schuh | 3da7b27 | 2020-01-06 18:41:40 -0800 | [diff] [blame] | 20 | LOG(FATAL) << "Can't allocate more memory with a fixed size allocator. " |
| 21 | "Increase the memory reserved."; |
Austin Schuh | 40485ed | 2019-10-26 21:51:44 -0700 | [diff] [blame] | 22 | return nullptr; |
| 23 | } |
| 24 | |
| 25 | } // namespace aos |