aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeandro A. F. Pereira <leandro@hardinfo.org>2007-01-03 21:13:15 +0000
committerLeandro A. F. Pereira <leandro@hardinfo.org>2007-01-03 21:13:15 +0000
commitb2d570a78ba003c7ead6096f37f3348b503db634 (patch)
tree777630afb8df3141b74f3d1255989b9bff43ca92
parent0196020beb33bff391c5810b07a8ce34ce709278 (diff)
Plug memleaks.
-rw-r--r--hardinfo2/arch/linux/common/devmemory.h26
-rw-r--r--hardinfo2/arch/linux/common/storage.h6
-rw-r--r--hardinfo2/devices.c3
-rw-r--r--hardinfo2/shell.c2
4 files changed, 21 insertions, 16 deletions
diff --git a/hardinfo2/arch/linux/common/devmemory.h b/hardinfo2/arch/linux/common/devmemory.h
index ca8ec4e6..c7ffdc08 100644
--- a/hardinfo2/arch/linux/common/devmemory.h
+++ b/hardinfo2/arch/linux/common/devmemory.h
@@ -18,7 +18,7 @@
static void __scan_memory()
{
- gchar **keys;
+ gchar **keys, *tmp;
gint i;
g_file_get_contents("/proc/meminfo", &meminfo, NULL, NULL);
@@ -26,23 +26,31 @@ static void __scan_memory()
keys = g_strsplit(meminfo, "\n", 0);
g_free(meminfo);
- meminfo = "";
-
g_free(lginterval);
- lginterval = "";
+
+ meminfo = g_strdup("");
+ lginterval = g_strdup("");
for (i = 0; keys[i]; i++) {
gchar **newkeys = g_strsplit(keys[i], ":", 0);
- if (!newkeys[0]) break;
+ if (!newkeys[0]) {
+ g_strfreev(newkeys);
+ break;
+ }
g_strstrip(newkeys[1]);
g_hash_table_replace(moreinfo, g_strdup(newkeys[0]), g_strdup(newkeys[1]));
- meminfo = g_strconcat(meminfo, newkeys[0], "=", newkeys[1], "\n", NULL);
- lginterval = g_strconcat(lginterval,
- "LoadGraphInterval$", newkeys[0], "=500\n",
- "UpdateInterval$", newkeys[0], "=500\n", NULL);
+ tmp = g_strconcat(meminfo, newkeys[0], "=", newkeys[1], "\n", NULL);
+ g_free(meminfo);
+ meminfo = tmp;
+
+ tmp = g_strconcat(lginterval,
+ "LoadGraphInterval$", newkeys[0], "=500\n",
+ "UpdateInterval$", newkeys[0], "=500\n", NULL);
+ g_free(lginterval);
+ lginterval = tmp;
g_strfreev(newkeys);
}
diff --git a/hardinfo2/arch/linux/common/storage.h b/hardinfo2/arch/linux/common/storage.h
index 8e248d3b..836ba7ea 100644
--- a/hardinfo2/arch/linux/common/storage.h
+++ b/hardinfo2/arch/linux/common/storage.h
@@ -22,8 +22,6 @@ static gboolean
remove_scsi_devices(gpointer key, gpointer value, gpointer data)
{
if (!strncmp((gchar *) key, "SCSI", 4)) {
- g_free((gchar *) key);
- g_free((GtkTreeIter *) value);
return TRUE;
}
return FALSE;
@@ -150,15 +148,11 @@ static gboolean
remove_ide_devices(gpointer key, gpointer value, gpointer data)
{
if (!strncmp((gchar *) key, "IDE", 3)) {
- g_free((gchar *) key);
- g_free((gchar *) value);
-
return TRUE;
}
return FALSE;
}
-
void
__scan_ide_devices(void)
{
diff --git a/hardinfo2/devices.c b/hardinfo2/devices.c
index 76d5204b..eb4cc3e7 100644
--- a/hardinfo2/devices.c
+++ b/hardinfo2/devices.c
@@ -291,7 +291,8 @@ callback_memory()
"ViewType=2\n"
"RescanInterval=2000\n"
"%s\n",
- meminfo, lginterval);
+ meminfo,
+ lginterval);
}
gchar *
diff --git a/hardinfo2/shell.c b/hardinfo2/shell.c
index 34fd1aea..3259697a 100644
--- a/hardinfo2/shell.c
+++ b/hardinfo2/shell.c
@@ -973,6 +973,8 @@ module_selected_show_info(ShellModuleEntry * entry, gboolean reload)
} else {
group_handle_normal(key_file, entry, group, keys, ngroups);
}
+
+ g_strfreev(keys);
}
gtk_tree_view_expand_all(GTK_TREE_VIEW(shell->info->view));