blob: 4f6497e5e44f82e319f8e6f5abfdcfbc9ddcf4d9 [file] [log] [blame]
Austin Schuh40485ed2019-10-26 21:51:44 -07001#include "aos/flatbuffers.h"
2
3#include "glog/logging.h"
4
5namespace aos {
6
Brian Silverman1715d472020-08-12 22:54:15 -07007uint8_t *FixedAllocatorBase::allocate(size_t allocated_size) {
Austin Schuh40485ed2019-10-26 21:51:44 -07008 if (is_allocated_) {
Austin Schuh3da7b272020-01-06 18:41:40 -08009 LOG(FATAL) << "Can't allocate more memory with a fixed size allocator. "
10 "Increase the memory reserved.";
Austin Schuh40485ed2019-10-26 21:51:44 -070011 }
Brian Silverman1715d472020-08-12 22:54:15 -070012 CHECK_LE(allocated_size, size());
Austin Schuh40485ed2019-10-26 21:51:44 -070013
14 is_allocated_ = true;
15 return data();
16}
17
18uint8_t *FixedAllocatorBase::reallocate_downward(uint8_t *, size_t, size_t,
19 size_t, size_t) {
Austin Schuh3da7b272020-01-06 18:41:40 -080020 LOG(FATAL) << "Can't allocate more memory with a fixed size allocator. "
21 "Increase the memory reserved.";
Austin Schuh40485ed2019-10-26 21:51:44 -070022 return nullptr;
23}
24
25} // namespace aos