From 0dcb91d60d6fc81f37bac1dc582a4bc0913e4bd0 Mon Sep 17 00:00:00 2001
From: Norihiro Watanabe <norihiro.w@gmail.com>
Date: Sat, 11 Oct 2014 22:20:39 +0200
Subject: [PATCH] make MemWatch class being accessible on any platforms, though
 it does nothing on Windows and Mac.

---
 BaseLib/MemWatch.cpp | 13 +++++++++++--
 BaseLib/MemWatch.h   | 19 ++++---------------
 2 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/BaseLib/MemWatch.cpp b/BaseLib/MemWatch.cpp
index 53a00233191..5672751c1c6 100644
--- a/BaseLib/MemWatch.cpp
+++ b/BaseLib/MemWatch.cpp
@@ -14,7 +14,14 @@
 
 #include "MemWatch.h"
 
-#ifndef _MSC_VER
+#if !defined(WIN32) && !defined(__APPLE__)
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <sstream>
+#include <sys/types.h>
+#include <unistd.h>
+#endif
 
 namespace BaseLib {
 
@@ -25,6 +32,7 @@ MemWatch::MemWatch ()
 
 unsigned MemWatch::updateMemUsage ()
 {
+#if !defined(WIN32) && !defined(__APPLE__)
         std::string fname ("/proc/");
         std::stringstream str_pid;
         str_pid << (unsigned) getpid();
@@ -48,6 +56,8 @@ unsigned MemWatch::updateMemUsage ()
         in >> pages;
         _cmem_size = ((unsigned long) pages) * ((unsigned long) getpagesize());
         in.close ();
+#endif
+
         return 0;
 }
 
@@ -74,4 +84,3 @@ unsigned long MemWatch::getCodeMemUsage () {
 
 } // end namespace BaseLib
 
-#endif // _MSC_VER
diff --git a/BaseLib/MemWatch.h b/BaseLib/MemWatch.h
index 3a9870b4deb..5f8fd6eab58 100644
--- a/BaseLib/MemWatch.h
+++ b/BaseLib/MemWatch.h
@@ -15,15 +15,6 @@
 #ifndef MEMWATCH_H_
 #define MEMWATCH_H_
 
-#ifndef _MSC_VER
-
-#include <sys/types.h>
-#include <unistd.h>
-#include <iostream>
-#include <fstream>
-#include <string>
-#include <sstream>
-
 namespace BaseLib {
 
 class MemWatch {
@@ -36,14 +27,12 @@ public:
 
 private:
 	unsigned updateMemUsage ();
-	unsigned long _vmem_size;
-	unsigned long _rmem_size;
-	unsigned long _smem_size;
-	unsigned long _cmem_size;
+	unsigned long _vmem_size = 0;
+	unsigned long _rmem_size = 0;
+	unsigned long _smem_size = 0;
+	unsigned long _cmem_size = 0;
 };
 
 }
 
-#endif // not Windows
-
 #endif /* MEMWATCH_H_ */
-- 
GitLab