We want to avoid allocating using the heap in case this program needs to be ported to a fully embedded system. However, allocating sensor contexts on the stack can use a lot of stack space since some contexts are quite large. Instead of doing this, a static buffer should be defined called an arena.
As sensors are created/initialized, the space required to store their contexts should be allocated from this arena instead of on the stack. This way we don't have a stack overflow.
Read more about arena allocators here. This article goes very in-depth about memory management.
We want to avoid allocating using the heap in case this program needs to be ported to a fully embedded system. However, allocating sensor contexts on the stack can use a lot of stack space since some contexts are quite large. Instead of doing this, a static buffer should be defined called an arena.
As sensors are created/initialized, the space required to store their contexts should be allocated from this arena instead of on the stack. This way we don't have a stack overflow.
Read more about arena allocators here. This article goes very in-depth about memory management.