xfree86: flatten pathlist management in the loader

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

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
This commit is contained in:
Emil Velikov 2016-04-17 21:07:30 +01:00 committed by Adam Jackson
parent 7b71055fc6
commit 778cfc5976

View File

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