jnterry / xeno-engine

Back to C style game engine
1 stars 0 forks source link

Convention for allocator and arena passing #9

Open jnterry opened 6 years ago

jnterry commented 6 years ago

Arenas and allocators are currently passed by both reference and by pointer to different functions, and constantly dereferencing and taking the address of them is a pain.

Decide on a convention, probably by reference as we don't want to allow them to be null (but do we need to allocate them on the heap???), and add to check_code_style.hpp

We also want move assignment operators for all of them (recently added for ArenaPool, might not be in others)

jnterry commented 6 years ago

It's probably best to use pointers to pass allocators around, since we want to be able to store them in POD structs, and we cant store references in structs without having a constructor.

Arenas could be passed around by reference, since we just store the arena struct as a member of a POD struct directly, no need to chase pointers.

Eg, struct Kernel { xen::Allocator* root_allocator; xen::ArenaPool<LoadedModule> modules; };