blob: 9fead132d671b70bb8728936839c674ce584d6b7 [file] [log] [blame]
Austin Schuh40485ed2019-10-26 21:51:44 -07001#include "aos/flatbuffers.h"
2
Austin Schuh99f7c6a2024-06-25 22:07:44 -07003#include "absl/log/check.h"
4#include "absl/log/log.h"
Austin Schuh40485ed2019-10-26 21:51:44 -07005
6namespace aos {
7
Brian Silverman1715d472020-08-12 22:54:15 -07008uint8_t *FixedAllocatorBase::allocate(size_t allocated_size) {
Austin Schuh40485ed2019-10-26 21:51:44 -07009 if (is_allocated_) {
Austin Schuh3da7b272020-01-06 18:41:40 -080010 LOG(FATAL) << "Can't allocate more memory with a fixed size allocator. "
11 "Increase the memory reserved.";
Austin Schuh40485ed2019-10-26 21:51:44 -070012 }
Brian Silverman1715d472020-08-12 22:54:15 -070013 CHECK_LE(allocated_size, size());
Austin Schuh40485ed2019-10-26 21:51:44 -070014
15 is_allocated_ = true;
16 return data();
17}
18
19uint8_t *FixedAllocatorBase::reallocate_downward(uint8_t *, size_t, size_t,
20 size_t, size_t) {
Austin Schuh3da7b272020-01-06 18:41:40 -080021 LOG(FATAL) << "Can't allocate more memory with a fixed size allocator. "
22 "Increase the memory reserved.";
Austin Schuh40485ed2019-10-26 21:51:44 -070023 return nullptr;
24}
25
26} // namespace aos