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β theSDL_IOStreamyou 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 beNULLif you literally don't care, and honestly? valid. πcloseioβ iftrue, it callsSDL_CloseIO()onsrcbefore 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
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms