aboutsummaryrefslogtreecommitdiff
path: root/modules/computer/memory.c
diff options
context:
space:
mode:
authorSimon Quigley <tsimonq2@ubuntu.com>2017-08-16 04:32:39 -0500
committerSimon Quigley <tsimonq2@ubuntu.com>2017-08-16 04:32:39 -0500
commit82306ca849c0710209e5a39754f446d0335a276d (patch)
tree8d297400e5c36357b9147401631e653e035283d3 /modules/computer/memory.c
parent21a53faf18b01a65a341115000e97d70b37c750c (diff)
parent9a9db98089717990cd5e0eef529f6bb0819ebe46 (diff)
Updated version 0.5.1+git20170815 from 'upstream/0.5.1+git20170815'
with Debian dir 36bf8e7e43d9f6621a63c79a597af2f4f76271b7
Diffstat (limited to 'modules/computer/memory.c')
-rw-r--r--modules/computer/memory.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/modules/computer/memory.c b/modules/computer/memory.c
index 3d320e8a..dc8599c2 100644
--- a/modules/computer/memory.c
+++ b/modules/computer/memory.c
@@ -28,23 +28,26 @@ computer_get_memory(void)
procmem = fopen("/proc/meminfo", "r");
if (!procmem)
- return NULL;
+ return NULL;
mi = g_new0(MemoryInfo, 1);
while (fgets(buffer, 128, procmem)) {
- gchar **tmp = g_strsplit(buffer, ":", 2);
-
- tmp[0] = g_strstrip(tmp[0]);
- tmp[1] = g_strstrip(tmp[1]);
-
- get_int("MemTotal", mi->total);
- get_int("MemFree", mi->free);
- get_int("Cached", mi->cached);
-
- g_strfreev(tmp);
+ gchar **tmp = g_strsplit(buffer, ":", 2);
+ if (tmp[1] == NULL) {
+ g_strfreev(tmp);
+ continue;
+ }
+ tmp[0] = g_strstrip(tmp[0]);
+ tmp[1] = g_strstrip(tmp[1]);
+
+ get_int("MemTotal", mi->total);
+ get_int("MemFree", mi->free);
+ get_int("Cached", mi->cached);
+
+ g_strfreev(tmp);
}
fclose(procmem);
-
+
mi->used = mi->total - mi->free;
mi->total /= 1000;