Skip to content

Commit 9b4168d

Browse files
authored
Deprecate intfstream_open_writable_memory (#18216)
1 parent 5b6c93a commit 9b4168d

3 files changed

Lines changed: 5 additions & 19 deletions

File tree

libretro-common/formats/png/rpng_encode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ uint8_t* rpng_save_image_bgr24_string(const uint8_t *data,
410410
if (!buf)
411411
GOTO_END_ERROR();
412412

413-
intf_s = intfstream_open_writable_memory(buf,
413+
intf_s = intfstream_open_memory(buf,
414414
RETRO_VFS_FILE_ACCESS_WRITE,
415415
RETRO_VFS_FILE_ACCESS_HINT_NONE,
416416
_len);

libretro-common/include/streams/interface_stream.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ intfstream_t *intfstream_open_file(const char *path,
121121
intfstream_t *intfstream_open_memory(void *data,
122122
unsigned mode, unsigned hints, uint64_t size);
123123

124+
/* Deprecated. Has the same effect as `intfstream_open_memory` with
125+
a mode including `RETRO_VFS_FILE_ACCESS_WRITE`. */
124126
intfstream_t *intfstream_open_writable_memory(void *data,
125127
unsigned mode, unsigned hints, uint64_t size);
126128

libretro-common/streams/interface_stream.c

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ intfstream_t *intfstream_open_memory(void *data,
713713
info.type = INTFSTREAM_MEMORY;
714714
info.memory.buf.data = (uint8_t*)data;
715715
info.memory.buf.size = size;
716-
info.memory.writable = false;
716+
info.memory.writable = (mode & RETRO_VFS_FILE_ACCESS_WRITE) != 0;
717717

718718
if (!(fd = (intfstream_t*)intfstream_init(&info)))
719719
return NULL;
@@ -729,23 +729,7 @@ intfstream_t *intfstream_open_memory(void *data,
729729
intfstream_t *intfstream_open_writable_memory(void *data,
730730
unsigned mode, unsigned hints, uint64_t size)
731731
{
732-
intfstream_info_t info;
733-
intfstream_t *fd = NULL;
734-
735-
info.type = INTFSTREAM_MEMORY;
736-
info.memory.buf.data = (uint8_t*)data;
737-
info.memory.buf.size = size;
738-
info.memory.writable = true;
739-
740-
if (!(fd = (intfstream_t*)intfstream_init(&info)))
741-
return NULL;
742-
743-
if (intfstream_open(fd, NULL, mode, hints))
744-
return fd;
745-
746-
intfstream_close(fd);
747-
free(fd);
748-
return NULL;
732+
return intfstream_open_memory(data, mode | RETRO_VFS_FILE_ACCESS_WRITE, hints, size);
749733
}
750734

751735
intfstream_t *intfstream_open_chd_track(const char *path,

0 commit comments

Comments
 (0)