Skip to content

Commit 93525a5

Browse files
authored
Merge pull request #104 from jameshanlon/fix-103
Use stol() for determining Linux memory use
2 parents bf0b272 + 13160c7 commit 93525a5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

linux/memory.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,21 @@ void mem_status( MemoryStatus & status )
6666
if( substr.compare( "MemTotal" ) == 0 )
6767
{
6868
// get total memory
69-
total_mem = stoi( line.substr( substr_start, substr_len ) );
69+
total_mem = stol( line.substr( substr_start, substr_len ) );
7070
}
7171
else if( substr.compare( "MemFree" ) == 0 )
7272
{
73-
used_mem = total_mem - stoi( line.substr( substr_start, substr_len ) );
73+
used_mem = total_mem - stol( line.substr( substr_start, substr_len ) );
7474
}
7575
else if( substr.compare( "Shmem" ) == 0 )
7676
{
77-
used_mem += stoi( line.substr( substr_start, substr_len ) );
77+
used_mem += stol( line.substr( substr_start, substr_len ) );
7878
}
7979
else if( substr.compare( "Buffers" ) == 0 ||
8080
substr.compare( "Cached" ) == 0 ||
8181
substr.compare( "SReclaimable" ) == 0 )
8282
{
83-
used_mem -= stoi( line.substr( substr_start, substr_len ) );
83+
used_mem -= stol( line.substr( substr_start, substr_len ) );
8484
}
8585
}
8686

0 commit comments

Comments
 (0)