[Xfce4-commits] [panel-plugins/xfce4-systemload-plugin] 01/01: Use MemAvailable on Linux 3.14+
noreply at xfce.org
noreply at xfce.org
Sun Jul 10 08:55:07 CEST 2016
This is an automated email from the git hooks/post-receive script.
landry pushed a commit to branch master
in repository panel-plugins/xfce4-systemload-plugin.
commit 224b30efc6d4bb71a99e56c5db4edb44a0520e74
Author: Kernc <kerncece at gmail.com>
Date: Sat Jul 9 00:36:40 2016 +0200
Use MemAvailable on Linux 3.14+
---
panel-plugin/memswap.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/panel-plugin/memswap.c b/panel-plugin/memswap.c
index c19cb69..9e218cb 100644
--- a/panel-plugin/memswap.c
+++ b/panel-plugin/memswap.c
@@ -50,6 +50,7 @@ static unsigned long MTotal = 0;
static unsigned long MFree = 0;
static unsigned long MBuffers = 0;
static unsigned long MCached = 0;
+static unsigned long MAvail = 0;
static unsigned long MUsed = 0;
static unsigned long STotal = 0;
static unsigned long SFree = 0;
@@ -59,7 +60,7 @@ gint read_memswap(gulong *mem, gulong *swap, gulong *MT, gulong *MU, gulong *ST,
{
int fd;
size_t n;
- char *b_MTotal, *b_MFree, *b_MBuffers, *b_MCached, *b_STotal, *b_SFree;
+ char *b_MTotal, *b_MFree, *b_MBuffers, *b_MCached, *b_MAvail, *b_STotal, *b_SFree;
if ((fd = open("/proc/meminfo", O_RDONLY)) < 0)
{
@@ -92,6 +93,15 @@ gint read_memswap(gulong *mem, gulong *swap, gulong *MT, gulong *MU, gulong *ST,
if (!b_MCached || !sscanf(b_MCached + strlen("Cached"), ": %lu", &MCached))
return -1;
+ /* In Linux 3.14+, use MemAvailable instead */
+ b_MAvail = strstr(MemInfoBuf, "MemAvailable");
+ if (b_MAvail && sscanf(b_MAvail + strlen("MemAvailable"), ": %lu", &MAvail))
+ {
+ MFree = MAvail;
+ MBuffers = 0;
+ MCached = 0;
+ }
+
b_STotal = strstr(MemInfoBuf, "SwapTotal");
if (!b_STotal || !sscanf(b_STotal + strlen("SwapTotal"), ": %lu", &STotal))
return -1;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list