Why on the platform layer we have function pointers inside functions? I do see this pattern very common, I don't know if handmade hero by any chance shares a similar architecture with Quake but on Quake 3 things like Hunk_Alloc and platform spesific things are stored inside something called "refresh module". What is the reason for doing this? I assume it is so that we can assign function pointers to platfrom spesific functions but why not just toggle which platform layer is included? Like have a simple check
#ifdef PLATFORM_WINDOWS #include "win32_platform.h" #else #include "linux_platform.h" #endif
And we do not need function pointers. Also we would be doing indirect access to functions when using function pointers so if we have them called inside a loop that would also impact the performance? What benefits do we get when doing things this way?