aboutsummaryrefslogtreecommitdiff
path: root/hardinfo2/arch/linux/common/devmemory.h
diff options
context:
space:
mode:
Diffstat (limited to 'hardinfo2/arch/linux/common/devmemory.h')
-rw-r--r--hardinfo2/arch/linux/common/devmemory.h26
1 files changed, 17 insertions, 9 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);
}