Skip to content

Commit d193748

Browse files
committed
Deprecate intfstream_open_writable_memory
The function is marked deprecated and rewritten in terms of `intfstream_open_memory`.
1 parent 7c30935 commit d193748

2 files changed

Lines changed: 4 additions & 18 deletions

File tree

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)