From d193748d501d3f4e6bbda0bde50676181171dc2e Mon Sep 17 00:00:00 2001 From: "Joseph C. Osborn" Date: Fri, 29 Aug 2025 12:41:01 -0700 Subject: [PATCH 1/2] Deprecate `intfstream_open_writable_memory` The function is marked deprecated and rewritten in terms of `intfstream_open_memory`. --- .../include/streams/interface_stream.h | 2 ++ libretro-common/streams/interface_stream.c | 20 ++----------------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/libretro-common/include/streams/interface_stream.h b/libretro-common/include/streams/interface_stream.h index 497025933571..5eef13baa9da 100644 --- a/libretro-common/include/streams/interface_stream.h +++ b/libretro-common/include/streams/interface_stream.h @@ -121,6 +121,8 @@ intfstream_t *intfstream_open_file(const char *path, intfstream_t *intfstream_open_memory(void *data, unsigned mode, unsigned hints, uint64_t size); +/* Deprecated. Has the same effect as `intfstream_open_memory` with + a mode including `RETRO_VFS_FILE_ACCESS_WRITE`. */ intfstream_t *intfstream_open_writable_memory(void *data, unsigned mode, unsigned hints, uint64_t size); diff --git a/libretro-common/streams/interface_stream.c b/libretro-common/streams/interface_stream.c index dad03aa87f3f..a5fbdb3c30af 100644 --- a/libretro-common/streams/interface_stream.c +++ b/libretro-common/streams/interface_stream.c @@ -713,7 +713,7 @@ intfstream_t *intfstream_open_memory(void *data, info.type = INTFSTREAM_MEMORY; info.memory.buf.data = (uint8_t*)data; info.memory.buf.size = size; - info.memory.writable = false; + info.memory.writable = (mode & RETRO_VFS_FILE_ACCESS_WRITE) != 0; if (!(fd = (intfstream_t*)intfstream_init(&info))) return NULL; @@ -729,23 +729,7 @@ intfstream_t *intfstream_open_memory(void *data, intfstream_t *intfstream_open_writable_memory(void *data, unsigned mode, unsigned hints, uint64_t size) { - intfstream_info_t info; - intfstream_t *fd = NULL; - - info.type = INTFSTREAM_MEMORY; - info.memory.buf.data = (uint8_t*)data; - info.memory.buf.size = size; - info.memory.writable = true; - - if (!(fd = (intfstream_t*)intfstream_init(&info))) - return NULL; - - if (intfstream_open(fd, NULL, mode, hints)) - return fd; - - intfstream_close(fd); - free(fd); - return NULL; + return intfstream_open_memory(data, mode | RETRO_VFS_FILE_ACCESS_WRITE, hints, size); } intfstream_t *intfstream_open_chd_track(const char *path, From 89580a3d1c2003c68fd9fa6126a82ec1367b577a Mon Sep 17 00:00:00 2001 From: "Joseph C. Osborn" Date: Fri, 29 Aug 2025 12:42:03 -0700 Subject: [PATCH 2/2] Remove the only use of `intfstream_open_writable_memory` in RA --- libretro-common/formats/png/rpng_encode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretro-common/formats/png/rpng_encode.c b/libretro-common/formats/png/rpng_encode.c index 15ccc69f951c..729f531518b3 100644 --- a/libretro-common/formats/png/rpng_encode.c +++ b/libretro-common/formats/png/rpng_encode.c @@ -410,7 +410,7 @@ uint8_t* rpng_save_image_bgr24_string(const uint8_t *data, if (!buf) GOTO_END_ERROR(); - intf_s = intfstream_open_writable_memory(buf, + intf_s = intfstream_open_memory(buf, RETRO_VFS_FILE_ACCESS_WRITE, RETRO_VFS_FILE_ACCESS_HINT_NONE, _len);