In Day 346 around the 29:00 mark, Casey writes this line in PLATFORM_DEALLOCATE_MEMORY, casting a platform_memory_block pointer to a win32_memory_block pointer to deallocate it:
#define PLATFORM_DEALLOCATE_MEMORY(name) void name(platform_memory_block *Block)
win32_memory_block *Win32Block = ((win32_memory_block *)Block);
The relevant structs are defined as below:
I think I understand how pseudo-polymorphism in C works, making use of the fact that the pointer to a struct is also a pointer to the first element in that struct, and if that element is also struct, then also a pointer to the first element in that struct and so on. Casey mentions this as well when he rearranges the win32_memory_block struct like the above configuration.
But I don't understand how the actual code he wrote is an example of this? The platform_memory_block struct does not have any knowledge of the win32_memory_block, so why does this code work?
I guess I am missing something obvious -- what is it?