[Commits] SDL: filesystem: QNX should use SDL_LoadFile() instead of rollin...

libsdl.org revision control commits-owner at libsdl.org
Wed Aug 16 23:58:51 PDT 2017


details:   https://hg.libsdl.org/SDL/rev/18bc7f7649d4
changeset: 11310:18bc7f7649d4
user:      Ryan C. Gordon <icculus at icculus.org>
date:      Thu Aug 17 02:58:46 2017 -0400
description:
filesystem: QNX should use SDL_LoadFile() instead of rolling it from scratch.

diffstat:

 src/filesystem/unix/SDL_sysfilesystem.c |  33 ++-------------------------------
 1 files changed, 2 insertions(+), 31 deletions(-)

diffs (50 lines):

diff -r e421d01ce5bf -r 18bc7f7649d4 src/filesystem/unix/SDL_sysfilesystem.c
--- a/src/filesystem/unix/SDL_sysfilesystem.c	Thu Aug 17 01:25:48 2017 -0400
+++ b/src/filesystem/unix/SDL_sysfilesystem.c	Thu Aug 17 02:58:46 2017 -0400
@@ -43,36 +43,7 @@
 #include "SDL_filesystem.h"
 
 /* QNX's /proc/self/exefile is a text file and not a symlink. */
-#if defined(__QNXNTO__)
-static char *
-readWholeFile(const char *path)
-{
-    char *retval = (char *) SDL_malloc(PATH_MAX+1);
-    if (retval != NULL)
-    {
-        const int fd = open(path, O_RDONLY);
-        const ssize_t br = (fd == -1) ? -1 : read(fd, retval, PATH_MAX);
-        char *ptr;
-
-        if (fd != -1)
-            close(fd);
-
-        if ((br < 0) || (br > PATH_MAX))
-        {
-            free(retval);
-            return NULL;
-        } /* if */
-
-        retval[br] = '\0';
-
-        ptr = (char *) SDL_realloc(retval, br + 1);
-        if (ptr != NULL)  /* just shrinking buffer; don't care if it failed. */
-            retval = ptr;
-    } /* else */
-
-    return retval;
-}
-#else
+#if !defined(__QNXNTO__)
 static char *
 readSymLink(const char *path)
 {
@@ -159,7 +130,7 @@
 #elif defined(__NETBSD__)
         retval = readSymLink("/proc/curproc/exe");
 #elif defined(__QNXNTO__)
-        retval = readWholeFile("/proc/self/exefile");
+        retval = SDL_LoadFile("/proc/self/exefile", NULL);
 #else
         retval = readSymLink("/proc/self/exe");  /* linux. */
         if (retval == NULL) {


More information about the commits mailing list