SDL_CloseIO(3)

πŸ’– SDL_CloseIO(3) πŸ’–

ok so bestie, we're in the SDL3 FUNCTIONS corner of the manual and today's main character is SDL_CloseIO 🫢


✨ NAME ✨

SDL_CloseIO β€” close and free an allocated SDL_IOStream structure. like, actually let it go. release it into the wild. πŸ¦‹


✨ SYNOPSIS ✨

#include <SDL3/SDL_iostream.h>

bool SDL_CloseIO(SDL_IOStream *context);

✨ DESCRIPTION ✨

okay so SDL_CloseIO() closes and cleans up the SDL_IOStream stream. it releases any resources used by the stream and frees the SDL_IOStream itself. that's the whole vibe: cleanup, then goodbye. πŸŽ€

it returns true on success, or false if the stream failed to flush to its output (e.g. to disk). 😭

note that if this fails to flush the stream for any reason, this function reports an error, but the SDL_IOStream is still invalid once this function returns. yes bestie, invalid. the object is gone either way, no take-backsies. πŸ’€

this call flushes any buffered writes to the operating system, but there are no guarantees that those writes have gone to physical media; they might be in the OS's file cache, waiting to go to disk later. πŸ‘€ so if it's absolutely crucial that writes go to disk immediately β€” like, they are definitely stored even if the power fails before the file cache would have caught up β€” one should call SDL_FlushIO() before closing. ⭐

note that flushing takes time and makes the system and your app operate less efficiently, so do so sparingly. it's giving "treat it like a special occasion, not a daily habit." πŸ’…


✨ FUNCTION PARAMETERS ✨

  • context β€” the SDL_IOStream structure to close. that's the one, hand it over 🫢

✨ RETURN VALUE ✨

Returns true on success or false on failure; call SDL_GetError() for more information. so if it goes wrong, the error message is right there waiting for you, no cap. πŸ”₯


✨ THREAD SAFETY ✨

Do not use the same SDL_IOStream from two threads at once. 🚫 two threads, one stream = chaos, and not the cute kind.


✨ AVAILABILITY ✨

This function is available since SDL 3.2.0. πŸ‘‘


✨ SEE ALSO ✨


Simple Directmedia Layer ✨ SDL 3.4.18 β€” mwah, that's the version, that's the source, and that's a wrap bestie πŸŽ€πŸ’– stream closed, resources freed, main character exit. periodt. 🌈

πŸ“¦ where this page comes from