From 5960cd80d2073d499c8390fe73a236c898f39cdc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 Dec 2017 17:59:18 +0100 Subject: [PATCH] Simplify filestream_read_file --- libretro-common/streams/file_stream.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index 36b9f94b3a..224fea7a5a 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -517,7 +517,7 @@ error: int filestream_read_file(const char *path, void **buf, ssize_t *len) { ssize_t ret = 0; - ssize_t content_buf_size = 0; + int64_t content_buf_size = 0; void *content_buf = NULL; RFILE *file = filestream_open(path, RETRO_VFS_FILE_ACCESS_READ, @@ -529,15 +529,11 @@ int filestream_read_file(const char *path, void **buf, ssize_t *len) goto error; } - if (filestream_seek(file, 0, SEEK_END) != 0) - goto error; + content_buf_size = filestream_get_size(file); - content_buf_size = filestream_tell(file); if (content_buf_size < 0) goto error; - filestream_rewind(file); - content_buf = malloc(content_buf_size + 1); if (!content_buf)