diff options
Diffstat (limited to 'src/Common')
-rw-r--r-- | src/Common/Backends/Makefile.in | 2 | ||||
-rw-r--r-- | src/Common/Backends/SystemBackendProc.cpp | 29 | ||||
-rw-r--r-- | src/Common/Makefile.in | 2 | ||||
-rw-r--r-- | src/Common/RequestHandlers/Makefile.in | 2 | ||||
-rw-r--r-- | src/Common/Requests/Makefile.in | 2 |
5 files changed, 14 insertions, 23 deletions
diff --git a/src/Common/Backends/Makefile.in b/src/Common/Backends/Makefile.in index d943c5e..f8f56a7 100644 --- a/src/Common/Backends/Makefile.in +++ b/src/Common/Backends/Makefile.in @@ -122,8 +122,6 @@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -PCRECPP_CFLAGS = @PCRECPP_CFLAGS@ -PCRECPP_LIBS = @PCRECPP_LIBS@ PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ READLINE_LIBS = @READLINE_LIBS@ diff --git a/src/Common/Backends/SystemBackendProc.cpp b/src/Common/Backends/SystemBackendProc.cpp index 51e14f8..e8c7357 100644 --- a/src/Common/Backends/SystemBackendProc.cpp +++ b/src/Common/Backends/SystemBackendProc.cpp @@ -19,8 +19,8 @@ #include "SystemBackendProc.h" -#include <pcrecpp.h> #include <cstdio> +#include <cstring> namespace Mad { namespace Common { @@ -58,26 +58,25 @@ SystemBackend::MemoryInfo SystemBackendProc::getMemoryInfo() { if(!meminfoFile.good()) return memInfo; - pcrecpp::RE re("(.+):\\s*(\\d+).*"); - while(!meminfoFile.eof() && meminfoFile.good()) { std::string line; std::getline(meminfoFile, line); - std::string name; + char *name = new char[line.length()+1]; // is always long enough unsigned long value; - if(!re.FullMatch(line, &name, &value)) - continue; - - if(name == "MemTotal") - memInfo.totalMem = value; - else if(name == "MemFree") - memInfo.freeMem = value; - else if(name == "SwapTotal") - memInfo.totalSwap = value; - else if(name == "SwapFree") - memInfo.freeSwap = value; + if(std::sscanf(line.c_str(), "%s %lu", name, &value) == 2) { + if(std::strcmp(name, "MemTotal:") == 0) + memInfo.totalMem = value; + else if(std::strcmp(name, "MemFree:") == 0) + memInfo.freeMem = value; + else if(std::strcmp(name, "SwapTotal:") == 0) + memInfo.totalSwap = value; + else if(std::strcmp(name, "SwapFree:") == 0) + memInfo.freeSwap = value; + } + + delete [] name; if(memInfo.totalMem && memInfo.freeMem && memInfo.totalSwap && memInfo.freeSwap) break; diff --git a/src/Common/Makefile.in b/src/Common/Makefile.in index 06e237f..02b537b 100644 --- a/src/Common/Makefile.in +++ b/src/Common/Makefile.in @@ -133,8 +133,6 @@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -PCRECPP_CFLAGS = @PCRECPP_CFLAGS@ -PCRECPP_LIBS = @PCRECPP_LIBS@ PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ READLINE_LIBS = @READLINE_LIBS@ diff --git a/src/Common/RequestHandlers/Makefile.in b/src/Common/RequestHandlers/Makefile.in index 905ea56..cca1c8e 100644 --- a/src/Common/RequestHandlers/Makefile.in +++ b/src/Common/RequestHandlers/Makefile.in @@ -122,8 +122,6 @@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -PCRECPP_CFLAGS = @PCRECPP_CFLAGS@ -PCRECPP_LIBS = @PCRECPP_LIBS@ PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ READLINE_LIBS = @READLINE_LIBS@ diff --git a/src/Common/Requests/Makefile.in b/src/Common/Requests/Makefile.in index 6d7b433..194a294 100644 --- a/src/Common/Requests/Makefile.in +++ b/src/Common/Requests/Makefile.in @@ -121,8 +121,6 @@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -PCRECPP_CFLAGS = @PCRECPP_CFLAGS@ -PCRECPP_LIBS = @PCRECPP_LIBS@ PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ READLINE_LIBS = @READLINE_LIBS@ |