SDL_WriteIO(3)
π SDL_WriteIO π
okay bestie, welcome to SDL_WriteIO(3) β the SDL3 FUNCTIONS girlie whose whole job is β¨writing to an SDL_IOStream data streamβ¨. no cap, that's literally it.
πΈ NAME πΈ
SDL_WriteIO β write to an SDL_IOStream data stream, fr fr π
β¨ SYNOPSIS β¨
#include <SDL3/SDL_iostream.h>
size_t SDL_WriteIO(SDL_IOStream *context, const void *ptr, size_t size);
π¦ DESCRIPTION π¦
so here's the vibe: this function writes exactly size bytes from the area that ptr is pointing at, straight into the stream. that's the dream, that's the goal, that's the main character moment π«Ά
but if it fails for literally any reason?? it'll return less than size to show you how far the write actually got. so you can see exactly where it gave up. on success, it returns size. slay. β
and here's the important part, no cap: on error, this function still attempts to write as much as possible, so it might hand you back a positive value that's less than the write size you asked for. it's doing its best, okay π
the caller can use SDL_GetIOStatus() to figure out if the problem is recoverable β like a non-blocking write that you can simply retry later β or a fatal error. so like, is it giving "just try again bestie" or is it giving "we're cooked" π
also!! a request for zero bytes on a valid stream will return zero immediately without even touching the stream, so the stream status (EOF, err, etc.) will not change. zero bytes = zero drama, periodt β¨
π FUNCTION PARAMETERS π
contextβ a pointer to anSDL_IOStreamstructure. this is the stream we're writing into, our canvas, our moment πptrβ a pointer to a buffer containing the data to write. the goods. the content. πsizeβ the number of bytes to write. how much we're serving today π
π RETURN VALUE π
Returns the number of bytes written π« β which will be less than size on failure. and if that happens, call SDL_GetError() for more info, because she will tell you what went wrong π£οΈ
π§ THREAD SAFETY π§
β οΈ do NOT use the same SDL_IOStream from two threads at once. that's it, that's the rule, one stream one thread, we do not share, we do not pass go π
π AVAILABILITY π
this function is available since SDL 3.2.0 β so if you're on anything older, sorry babe, she's not there yet π
β SEE ALSO β
go read those too, they're all part of the same friend group π«Ά
and that's the whole page, bestie!! this lil writeup came to you from Simple Directmedia Layer, rocking version SDL 3.4.18 πβ¨ mwah, go write some bytes, you're gonna ate ππ¦π
π¦ 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