Custom Memory Pool Allocator
Implement a custom fixed-size memory pool allocator in C++ suitable for embedded systems without dynamic memory allocation. Allocate blocks from a statically allocated pool and free them using a free list.
Constraints
- Pool size configurable via template.
- Block size fixed (e.g., 32 bytes).
- free_list stores pointers to free blocks.
- alloc() returns void* or nullptr.
- free_block() returns block to pool.
- No malloc/new.
1#include <stdint.h>2template<int N>3class Pool {4public:5 void* alloc();6 void free_block(void* p);7};