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