Clever ways of using context allocators?

By default oding pass around a struct what holds a bunch of pointers, that allows you to do stuff without changing functions signatures and much more. I feel like I’m not taking full advantage of context allocator’s. So it would be cool if people shared their tricks using custom allocators.

The point is that you are not meant to do anything clever with context in the first place.

Some people change the default context.allocator to something like the mem.Tracking_Allocator or even the panic_allocator, but that’s about it.

The point of the context is to override/intercept third party code, not as a shorthand not pass allocators around, per se. I expect most people do not use custom allocators whatsoever and still do the make/new/free style of allocation, and as such, the context is assumed to be untouched.

5 Likes

Interesting! This was never explained anywhere and I had assumed it was a wade to override the default allocator. I’ve come to passing around allocators in parameters in my code myself

2 Likes