loader: Remove unused path and name from ModuleDescPtr

Just a waste of memory. Path was never referenced at all, and name was
only used when unloading the module; we can just as well get the
module's internal idea of its name from VersionInfo.

Reviewed-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
Adam Jackson 2016-04-14 15:30:35 -04:00
parent 8920dca009
commit 8e83eacb9e
2 changed files with 9 additions and 24 deletions

View File

@ -59,8 +59,6 @@ typedef struct module_desc {
struct module_desc *child;
struct module_desc *sib;
struct module_desc *parent;
char *name;
char *path;
void *handle;
ModuleSetupProc SetupProc;
ModuleTearDownProc TearDownProc;

View File

@ -600,17 +600,6 @@ LoadSubModule(void *_parent, const char *module,
return submod;
}
static ModuleDescPtr
NewModuleDesc(const char *name)
{
ModuleDescPtr mdp = calloc(1, sizeof(ModuleDesc));
if (mdp)
mdp->name = xstrdup(name);
return mdp;
}
ModuleDescPtr
DuplicateModule(ModuleDescPtr mod, ModuleDescPtr parent)
{
@ -619,7 +608,7 @@ DuplicateModule(ModuleDescPtr mod, ModuleDescPtr parent)
if (!mod)
return NULL;
ret = NewModuleDesc(mod->name);
ret = calloc(1, sizeof(ModuleDesc));
if (ret == NULL)
return NULL;
@ -632,7 +621,6 @@ DuplicateModule(ModuleDescPtr mod, ModuleDescPtr parent)
ret->sib = DuplicateModule(mod->sib, parent);
ret->parent = parent;
ret->VersionInfo = mod->VersionInfo;
ret->path = strdup(mod->path);
return ret;
}
@ -726,7 +714,7 @@ LoadModule(const char *module, void *options, const XF86ModReqInfo *modreq,
*errmaj = LDR_BADUSAGE;
goto LoadModule_fail;
}
ret = NewModuleDesc(name);
ret = calloc(1, sizeof(ModuleDesc));
if (!ret) {
if (errmaj)
*errmaj = LDR_NOMEM;
@ -773,7 +761,6 @@ LoadModule(const char *module, void *options, const XF86ModReqInfo *modreq,
ret->handle = LoaderOpen(found, errmaj);
if (ret->handle == NULL)
goto LoadModule_fail;
ret->path = strdup(found);
/* drop any explicit suffix from the module name */
p = strchr(name, '.');
@ -857,31 +844,31 @@ void
UnloadModule(void *_mod)
{
ModuleDescPtr mod = _mod;
const char *name;
if (mod == (ModuleDescPtr) 1)
return;
if (mod == NULL || mod->name == NULL)
if (mod == NULL)
return;
name = mod->VersionInfo->modname;
if (mod->parent)
LogMessageVerbSigSafe(X_INFO, 3, "UnloadSubModule: \"%s\"\n",
mod->name);
LogMessageVerbSigSafe(X_INFO, 3, "UnloadSubModule: \"%s\"\n", name);
else
LogMessageVerbSigSafe(X_INFO, 3, "UnloadModule: \"%s\"\n", mod->name);
LogMessageVerbSigSafe(X_INFO, 3, "UnloadModule: \"%s\"\n", name);
if (mod->TearDownData != ModuleDuplicated) {
if ((mod->TearDownProc) && (mod->TearDownData))
mod->TearDownProc(mod->TearDownData);
LoaderUnload(mod->name, mod->handle);
LoaderUnload(name, mod->handle);
}
if (mod->child)
UnloadModule(mod->child);
if (mod->sib)
UnloadModule(mod->sib);
free(mod->path);
free(mod->name);
free(mod);
}