[PATCH xserver 04/19] xfree86: flatten pathlist management in the loader

Adam Jackson ajax at redhat.com
Mon Jan 23 19:32:18 UTC 2017


From: Emil Velikov <emil.l.velikov at gmail.com>

Now that used can set the path only via LoaderSetPath(), we can simplify
things.

Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
 hw/xfree86/loader/loadmod.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c
index 5e4d7da..fd61a82 100644
--- a/hw/xfree86/loader/loadmod.c
+++ b/hw/xfree86/loader/loadmod.c
@@ -127,9 +127,6 @@ InitPathList(const char *path)
     int addslash;
     int n = 0;
 
-    if (!path)
-        return defaultPathList;
-
     fullpath = strdup(path);
     if (!fullpath)
         return NULL;
@@ -171,13 +168,6 @@ InitPathList(const char *path)
     return list;
 }
 
-static void
-FreePathList(char **pathlist)
-{
-    if (pathlist && pathlist != defaultPathList)
-        FreeStringList(pathlist);
-}
-
 void
 LoaderSetPath(const char *path)
 {
@@ -498,7 +488,7 @@ LoaderListDirs(const char **subdirlist, const char **patternlist)
     char **ret = NULL;
     int n = 0;
 
-    if (!(pathlist = InitPathList(NULL)))
+    if (!(pathlist = defaultPathList))
         return NULL;
     if (!(subdirs = InitSubdirs(subdirlist)))
         goto bail;
@@ -565,7 +555,6 @@ LoaderListDirs(const char **subdirlist, const char **patternlist)
  bail:
     FreePatterns(patterns);
     FreeSubdirs(subdirs);
-    FreePathList(pathlist);
     return (const char **) ret;
 }
 
@@ -908,7 +897,7 @@ LoadModule(const char *module, const char **subdirlist,
         goto LoadModule_fail;
     }
 
-    pathlist = InitPathList(NULL);
+    pathlist = defaultPathList;
     if (!pathlist) {
         /* This could be a malloc failure too */
         if (errmaj)
@@ -1033,7 +1022,6 @@ LoadModule(const char *module, const char **subdirlist,
     ret = NULL;
 
  LoadModule_exit:
-    FreePathList(pathlist);
     FreePatterns(patterns);
     free(found);
     free(name);
-- 
2.9.3



More information about the xorg-devel mailing list