Deterministic Fixed Allocator
A hard-real-time task cannot use a general allocator because worst-case time is unbounded. Implement a bump allocator with a reset point and prove its allocation is constant time.
Constraints
- Fixed 4 KB arena, statically allocated.
- `allocate(bytes, alignment)` returns nullptr when it will not fit.
- Individual frees are not supported; only a full `reset()`.
- Allocation must be O(1) with no search.
- Alignment must be honoured exactly.
- Must not overflow when bytes is huge.
1#include <cstddef>2#include <cstdint>3 4class BumpAllocator {5public:6 void* allocate(size_t bytes, size_t alignment);7 void reset();8};