aboutsummaryrefslogtreecommitdiff
path: root/hardinfo2
diff options
context:
space:
mode:
authorLeandro Pereira <leandro@hardinfo.org>2010-01-03 17:19:07 -0200
committerLeandro Pereira <leandro@hardinfo.org>2010-01-03 17:19:07 -0200
commit93f39a984398e9f4d187b66eb272ec0bf48845e0 (patch)
tree35a14aa48a17c5281a9e6e697aac734233afa9e4 /hardinfo2
parentc8bc96a5431c1435be52a268d5a14c13ef90006d (diff)
Add a module deinitialization function, so modules can deallocate memory on unload.
Diffstat (limited to 'hardinfo2')
-rw-r--r--hardinfo2/computer.c45
-rw-r--r--hardinfo2/computer.h16
-rw-r--r--hardinfo2/shell.h1
-rw-r--r--hardinfo2/util.c5
4 files changed, 51 insertions, 16 deletions
diff --git a/hardinfo2/computer.c b/hardinfo2/computer.c
index 98936598..bbab7060 100644
--- a/hardinfo2/computer.c
+++ b/hardinfo2/computer.c
@@ -581,6 +581,50 @@ gchar **hi_module_get_dependencies(void)
return deps;
}
+void hi_module_deinit(void)
+{
+ DEBUG("cleaning up module");
+
+ if (computer->os) {
+ g_free(computer->os->kernel);
+ g_free(computer->os->libc);
+ g_free(computer->os->distrocode);
+ g_free(computer->os->distro);
+ g_free(computer->os->hostname);
+ g_free(computer->os->language);
+ g_free(computer->os->homedir);
+ g_free(computer->os->kernel_version);
+ g_free(computer->os->languages);
+ g_free(computer->os->desktop);
+ g_free(computer->os->username);
+ g_free(computer->os->boots);
+ g_free(computer->os);
+ }
+
+ if (computer->display) {
+ g_free(computer->display->ogl_vendor);
+ g_free(computer->display->ogl_renderer);
+ g_free(computer->display->ogl_version);
+ g_free(computer->display->display_name);
+ g_free(computer->display->vendor);
+ g_free(computer->display->version);
+ g_free(computer->display->extensions);
+ g_free(computer->display->monitors);
+ g_free(computer->display);
+ }
+
+ if (computer->alsa) {
+ g_slist_free(computer->alsa->cards);
+ g_free(computer->alsa);
+ }
+
+ g_free(computer->date_time);
+ g_free(computer);
+
+ h_hash_table_remove_all(moreinfo);
+ g_hash_table_destroy(moreinfo);
+}
+
void hi_module_init(void)
{
computer = g_new0(Computer, 1);
@@ -600,3 +644,4 @@ ModuleAbout *hi_module_get_about(void)
return ma;
}
+
diff --git a/hardinfo2/computer.h b/hardinfo2/computer.h
index a0c90d8f..ff84c271 100644
--- a/hardinfo2/computer.h
+++ b/hardinfo2/computer.h
@@ -118,22 +118,6 @@ struct _Computer {
gchar *date_time;
};
-struct _Processor {
- gchar *model_name;
- gchar *vendor_id;
- gchar *flags;
- gint cache_size;
- gfloat bogomips, cpu_mhz;
-
- gchar *has_fpu;
- gchar *bug_fdiv, *bug_hlt, *bug_f00f, *bug_coma;
-
- gint model, family, stepping;
- gchar *strmodel;
-
- gint id;
-};
-
struct _OperatingSystem {
gchar *kernel;
gchar *libc;
diff --git a/hardinfo2/shell.h b/hardinfo2/shell.h
index 736e41cd..90e7bdc1 100644
--- a/hardinfo2/shell.h
+++ b/hardinfo2/shell.h
@@ -130,6 +130,7 @@ struct _ShellModule {
GdkPixbuf *icon;
GModule *dll;
gpointer (*aboutfunc) ();
+ void (*deinit) ();
guchar weight;
diff --git a/hardinfo2/util.c b/hardinfo2/util.c
index 87521028..43a3677e 100644
--- a/hardinfo2/util.c
+++ b/hardinfo2/util.c
@@ -593,6 +593,9 @@ static void module_unload(ShellModule * module)
if (module->dll) {
gchar *name;
+ if (module->deinit)
+ module->deinit();
+
name = g_path_get_basename(g_module_name(module->dll));
g_hash_table_foreach_remove(__module_methods, remove_module_methods, name);
@@ -697,6 +700,8 @@ static ShellModule *module_load(gchar * filename)
g_module_symbol(module->dll, "hi_module_get_about",
(gpointer) & (module->aboutfunc));
+ g_module_symbol(module->dll, "hi_module_deinit",
+ (gpointer) & (module->deinit));
entries = get_module_entries();
while (entries[i].name) {