SDL_LoadFile_IO(3)

πŸ’– SDL_LoadFile_IO(3) πŸ’–

okay so bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where today's main character is SDL_LoadFile_IO β€” she loads all the data from an SDL data stream and she does it flawlessly, no cap.


✨ NAME ✨

SDL_LoadFile_IO β€” Load all the data from an SDL data stream. 🫢


✨ SYNOPSIS ✨

#include <SDL3/SDL_iostream.h>

void * SDL_LoadFile_IO(SDL_IOStream *src, size_t *datasize, bool closeio);

look at her. three params, zero drama. πŸ’…


✨ DESCRIPTION ✨

so the data gets allocated with a zero byte at the end (null terminated, iconic behavior honestly) just for convenience. and bestie, listen β€” that extra byte is not included in the value reported via datasize. it's a bonus byte. a little treat. πŸŽ€

and when you're done with the data? you free it with SDL_free(). that's the rule. no leaking, we don't do that here. 😭


✨ FUNCTION PARAMETERS ✨

  • src β€” the SDL_IOStream you wanna read all available data from. your source, your vibe, your stream. 🌊
  • datasize β€” a pointer that gets filled in with the number of bytes read. it may be NULL if you literally don't care, and honestly? valid. πŸ’…
  • closeio β€” if true, it calls SDL_CloseIO() on src before returning, even in the case of an error. so like, she's closing that door on her way out no matter what happened in the room. periodt. πŸšͺ

✨ RETURN VALUE ✨

returns the data, or NULL on failure. if you get NULL, call SDL_GetError() for more information β€” she will tell you what went wrong, she's not mysterious like that. πŸ”


✨ THREAD SAFETY ✨

do not use the same SDL_IOStream from two threads at once. i'm so serious. that's not a vibe check you want to fail. πŸ’€

✨ AVAILABILITY ✨

this function is available since SDL 3.2.0. so if you're on anything older, no she's not there yet, sorry bestie. 🌱


✨ SEE ALSO ✨

go read those too, they're part of the friend group. 🌈


and that's the whole page, bestie!! brought to you by Simple Directmedia Layer, running SDL 3.4.18, from the SDL_LoadFile_IO(3) page itself. stay null-terminated, stay freed, stay slay. πŸ’œβœ¨πŸ‘‘

πŸ“¦ where this page comes from