summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2016-04-14 15:30:35 -0400
committerAdam Jackson <ajax@redhat.com>2017-01-25 14:22:06 -0500
commit8e83eacb9e2d2c6c2b9f8cdb9e82c976a0237f24 (patch)
tree0ad454e5ad1663c92b91df56ef86de2df4d38b48
parent8920dca0091675f1202c1198336cd4d8e0259100 (diff)
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>
-rw-r--r--hw/xfree86/loader/loaderProcs.h2
-rw-r--r--hw/xfree86/loader/loadmod.c31
2 files changed, 9 insertions, 24 deletions
diff --git a/hw/xfree86/loader/loaderProcs.h b/hw/xfree86/loader/loaderProcs.h
index 84ed10310..8b16cb7ea 100644
--- a/hw/xfree86/loader/loaderProcs.h
+++ b/hw/xfree86/loader/loaderProcs.h
@@ -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;
diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c
index fc982c74c..cb86925b9 100644
--- a/hw/xfree86/loader/loadmod.c
+++ b/hw/xfree86/loader/loadmod.c
@@ -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);
}