Search code examples
csdlsdl-1.2

Is SDL_FreeSurface() equivalent to free() in terms of functionality?


I'm trying to free a bunch of things with different types, and so I think I might be able to free all of them using one function by adding them to a pile of void * cells.

My question is: is it safe to save an SDL_Surface* as void * and use the free() function without the need of SDL_FreeSurface()?


Solution

  • No, you have to use SDL_FreeSurface. (Evidence: what it does)

    Except in specific cases, it's never safe to just use one free function instead of another. You free things you allocate with malloc. You CloseHandle things opened with CreateFile (on Windows). You fclose files you opened with fopen. And so on.