core::IArena is an interface that abstracts heap-like allocator. It is typically implemented by core::HeapArena.
We have two classes that can be constructed either with or without IArena: core::Array and core::Hashmap. When constructed with arena, they use it to grow dynamically, otherwise they can only store data that fits within embedded capacity. The latter is used when we need container but want to be sure that it never allocates.
It would be nice to make this second feature a bit more explicit, and instead of a constructor overload without IArena, use a special arena that does not allocate.
Steps:
Add new header roc_core/noop_arena.h with something like this:
class NoopArenaImpl : public IArena {
...
};
static NoopArenaImpl NoopArena;
In Array and Hashmap, remove constructor overload without arena. Also remove internal logic that supports arena to be NULL.
In places where that constructor was used, instead use NoopArena like this:
: array_(core::NoopArena)
There are several tests that have NoMemArena. Search for those tests, remove NoMemArena, and instead reuse core::NoopArena.
core::IArena is an interface that abstracts heap-like allocator. It is typically implemented by core::HeapArena.
We have two classes that can be constructed either with or without IArena:
core::Array
andcore::Hashmap
. When constructed with arena, they use it to grow dynamically, otherwise they can only store data that fits within embedded capacity. The latter is used when we need container but want to be sure that it never allocates.It would be nice to make this second feature a bit more explicit, and instead of a constructor overload without IArena, use a special arena that does not allocate.
Steps:
Add new header
roc_core/noop_arena.h
with something like this:In Array and Hashmap, remove constructor overload without arena. Also remove internal logic that supports arena to be NULL.
In places where that constructor was used, instead use NoopArena like this:
There are several tests that have NoMemArena. Search for those tests, remove NoMemArena, and instead reuse core::NoopArena.