SDL_IOFromDynamicMem(3)

πŸ’– SDL_IOFromDynamicMem(3) πŸ’–

okay so bestie, welcome to the SDL3 FUNCTIONS corner of the manual, and today's main character is SDL_IOFromDynamicMem ✨


🌸 NAME 🌸

SDL_IOFromDynamicMem β€” use this function to make an SDL_IOStream that's backed by dynamically allocated memory. that's it, that's the whole vibe 🫢


✨ SYNOPSIS ✨

#include <SDL3/SDL_iostream.h>

SDL_IOStream * SDL_IOFromDynamicMem(void);

no arguments, no drama, just vibes πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so like, this stream is lowkey self-growing: it supports the following properties so you can get at the memory and also control how allocations happen πŸ‘‘

  • SDL_PROP_IOSTREAM_DYNAMIC_MEMORY_POINTER β€” a pointer to the internal memory of the stream. you can set this to NULL to transfer ownership of the memory to the application, and then the application should free that memory with SDL_free(). and here's the part you cannot skip, bestie: if you do this, the next operation on the stream must be SDL_CloseIO(). no cap, that's the rule 😭
  • SDL_PROP_IOSTREAM_DYNAMIC_CHUNKSIZE_NUMBER β€” memory gets allocated in multiples of this size, and it defaults to 1024. cute, right? πŸŽ€

πŸŽ€ RETURN VALUE πŸŽ€

returns a pointer to a shiny new SDL_IOStream structure, or NULL if it fails πŸ˜”. if it fails, call SDL_GetError() for more info, she'll tell you what went wrong 🫢


πŸ’œ THREAD SAFETY πŸ’œ

it is safe to call this function from any thread. go off, multithreaded queen πŸ‘‘


🌈 AVAILABILITY 🌈

this function has been available since SDL 3.2.0 ⭐


πŸ‘‘ SEE ALSO πŸ‘‘


okay that's the whole page, mwah πŸ’‹ this was brought to you by Simple Directmedia Layer, version SDL 3.4.18 β€” she ate and left no crumbs, periodt πŸ’…βœ¨πŸ“

πŸ“¦ where this page comes from