SDL_FreeSurface(3)

✨ NAME ✨

SDL_FreeSurface β€” bestie, this one frees (aka deletes) a SDL_Surface πŸ’…

It's from the SDL API Reference manual, page SDL_FreeSurface(3), and it's literally the little cleanup queen you call when you're done with a surface. Obsessed. πŸŽ€


🌸 SYNOPSIS 🌸

#include "SDL.h"

void SDL_FreeSurface(SDL_Surface *surface);

That's it. One function, one pointer, zero drama. πŸ¦‹


πŸ’– DESCRIPTION πŸ’–

So like, SDL_FreeSurface frees the resources used by a previously created SDL_Surface. You made a surface, you had your moment, now you release it back into the wild. Main character exit. 🌈

⚠️ BUT β€” important plot twist β€” if the surface was created using SDL_CreateRGBSurfaceFrom, then the pixel data is not freed. Not me warning you so you don't leak your own pixels bestie 😭 SDL_CreateRGBSurfaceFrom is the one that doesn't own its pixels, so SDL_FreeSurface is not gonna touch them. No cap.

πŸ‘‘ SEE ALSO πŸ‘‘

  • SDL_CreateRGBSurface β€” the icon that makes surfaces the normal way
  • SDL_CreateRGBSurfaceFrom β€” the one that borrows your pixels (and that's why they don't get freed here 🫢)

Okay that's the whole page, you ate it, go free your surfaces responsibly βœ¨πŸ’œ

SDL, Tue 11 Sep 2001, 23:01 β€” from the SDL_FreeSurface(3) era, still slaying, bye bestie πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from