Init, errors & main callbacksSDL 3.2
SDL_free
Frees memory that an SDL function allocated and handed to you.
Signature
void SDL_free(void *mem);
How it works
Some SDL functions return a block of memory that becomes yours: SDL_LoadFile, SDL_LoadWAV, SDL_GetPrefPath. Free those with SDL_free, not with free or delete. SDL may use its own allocator, and mixing allocators corrupts memory.
Each function's page says whether its result must be freed. Read-only results such as SDL_GetBasePath or SDL_GetError are owned by SDL and must NOT be freed.
Parameters
memvoid *
The pointer SDL gave you. NULL is allowed and does nothing.
Example
example.cpp
1char* prefs = SDL_GetPrefPath("MyStudio", "MyGame");
2std::string savePath = std::string(prefs) + "save1.dat";
3SDL_free(prefs);