Add properties to SDL_IOStreams returned by IOFromMem

This commit is contained in:
Ethan Lee
2024-10-01 17:50:59 -04:00
committed by Sam Lantinga
parent 1bb7e2b1a8
commit a0de6c4abf
2 changed files with 29 additions and 0 deletions

View File

@@ -793,6 +793,12 @@ SDL_IOStream *SDL_IOFromMem(void *mem, size_t size)
SDL_IOStream *iostr = SDL_OpenIO(&iface, iodata);
if (!iostr) {
SDL_free(iodata);
} else {
const SDL_PropertiesID props = SDL_GetIOProperties(iostr);
if (props) {
SDL_SetPointerProperty(props, SDL_PROP_IOSTREAM_MEMORY_POINTER, mem);
SDL_SetNumberProperty(props, SDL_PROP_IOSTREAM_MEMORY_SIZE_NUMBER, size);
}
}
return iostr;
}
@@ -827,6 +833,12 @@ SDL_IOStream *SDL_IOFromConstMem(const void *mem, size_t size)
SDL_IOStream *iostr = SDL_OpenIO(&iface, iodata);
if (!iostr) {
SDL_free(iodata);
} else {
const SDL_PropertiesID props = SDL_GetIOProperties(iostr);
if (props) {
SDL_SetPointerProperty(props, SDL_PROP_IOSTREAM_MEMORY_POINTER, (void *)mem);
SDL_SetNumberProperty(props, SDL_PROP_IOSTREAM_MEMORY_SIZE_NUMBER, size);
}
}
return iostr;
}