From 13160c7e801c7b60d60ba32ef16682ab3d21c28f Mon Sep 17 00:00:00 2001 From: James Hanlon Date: Wed, 22 May 2024 09:23:58 +0100 Subject: [PATCH] Use stol() for determining Linux memory use To acommodate large memory machines. --- linux/memory.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/linux/memory.cc b/linux/memory.cc index 4bcc295..baa9403 100644 --- a/linux/memory.cc +++ b/linux/memory.cc @@ -66,21 +66,21 @@ void mem_status( MemoryStatus & status ) if( substr.compare( "MemTotal" ) == 0 ) { // get total memory - total_mem = stoi( line.substr( substr_start, substr_len ) ); + total_mem = stol( line.substr( substr_start, substr_len ) ); } else if( substr.compare( "MemFree" ) == 0 ) { - used_mem = total_mem - stoi( line.substr( substr_start, substr_len ) ); + used_mem = total_mem - stol( line.substr( substr_start, substr_len ) ); } else if( substr.compare( "Shmem" ) == 0 ) { - used_mem += stoi( line.substr( substr_start, substr_len ) ); + used_mem += stol( line.substr( substr_start, substr_len ) ); } else if( substr.compare( "Buffers" ) == 0 || substr.compare( "Cached" ) == 0 || substr.compare( "SReclaimable" ) == 0 ) { - used_mem -= stoi( line.substr( substr_start, substr_len ) ); + used_mem -= stol( line.substr( substr_start, substr_len ) ); } }