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