sdlxOpenIo function iostream

Pointer<SdlIoStream> sdlxOpenIo(
  1. SdlxIoStreamInterface iface,
  2. Pointer<Void> userdata
)

Create a custom SDL_IOStream.

Applications do not need to use this function unless they are providing their own SDL_IOStream implementation. If you just need an SDL_IOStream to read/write a common data source, you should use the built-in implementations in SDL, like SDL_IOFromFile() or SDL_IOFromMem(), etc.

This function makes a copy of iface and the caller does not need to keep it around after this call.

\param iface the interface that implements this SDL_IOStream, initialized using SDL_INIT_INTERFACE(). \param userdata the pointer that will be passed to the interface functions. \returns a pointer to the allocated memory on success or NULL on failure; call SDL_GetError() for more information.

\threadsafety It is safe to call this function from any thread.

\since This function is available since SDL 3.2.0.

\sa SDL_CloseIO \sa SDL_INIT_INTERFACE \sa SDL_IOFromConstMem \sa SDL_IOFromFile \sa SDL_IOFromMem

extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_OpenIO(const SDL_IOStreamInterface *iface, void *userdata)

See also:

Implementation

Pointer<SdlIoStream> sdlxOpenIo(
  SdlxIoStreamInterface iface,
  Pointer<Void> userdata,
) {
  final ifacePointer = iface.calloc();
  final result = sdlOpenIo(ifacePointer, userdata);
  ifacePointer.callocFree();
  return result;
}