This commit is contained in:
Alex Cope 2023-06-30 11:05:12 -07:00
parent b3492b5084
commit 4b72775a5c

View File

@ -2,14 +2,14 @@
#include <fstream> #include <fstream>
static size_t getMemKey(std::string key) { static size_t getMemKey(std::string key) {
// # ifdef __linux__ # ifdef __linux__
std::string token; std::string token;
std::ifstream f("/proc/meminfo"); std::ifstream f("/proc/meminfo");
while (f >> token) { while (f >> token) {
if (token == key) { if (token == key) {
size_t mem_val; size_t mem_val;
if (f >> mem_val) { if (f >> mem_val) {
return mem_val; return mem_val * 1024; // values are in kB
} else { } else {
return 0; return 0;
} }
@ -17,9 +17,9 @@ static size_t getMemKey(std::string key) {
} }
} }
return 0; return 0;
// # else # else
// return 0; return 0;
// # endif # endif
} }
size_t getMemAvailable() { size_t getMemAvailable() {