Custom memory functions with SDL callbacks

Is it safe to call SDL_SetMemoryFunctions when using SDL with main callbacks? Setting these is the first thing done in app init.

1 Like

Yes, as long as it’s the absolutely first thing done in SDL_AppInit(), this is guaranteed to work.

.

1 Like

Hmm. Okay, thanks. I’m getting an invalid memory access when one of the subsystem init calls frees memory that has been calloc’d. I’ll do some more digging - highly likely I’m doing something silly!

Not by the computer to check, but think I found the issue looking at my source code on GH.

I call a function to allocate a block of memory, then log that this has been done, before setting the memory functions.

I bet that log call is what’s causing the problem.

1 Like

Yes, that and a call to register a custom log category for the memory system.

Is there a way to log that doesn’t allocate?