OSDN Git Service

Revert "ksysguard: remove the memory leaking scan_one()"
authorIvailo Monev <xakepa10@gmail.com>
Sat, 14 Mar 2015 00:23:55 +0000 (00:23 +0000)
committerIvailo Monev <xakepa10@gmail.com>
Sat, 14 Mar 2015 00:23:55 +0000 (00:23 +0000)
This reverts commit dd535ac6f8bcceff75804dfd4eaca6df894e6c70.

ksysguard/ksysguardd/Linux/Memory.c

index 21f6b77..6b2fcab 100644 (file)
@@ -46,8 +46,22 @@ static unsigned long long STotal = 0;
 static unsigned long long SFree = 0;
 static unsigned long long SUsed = 0;
 
+static void scan_one( const char* buff, const char *key, unsigned long long* val )
+{   
+  int o;
+  char *b = strstr( buff, key );
+  if ( b )  
+    o = sscanf( b + strlen( key ), ": %llu", val );
+}
+
 static void processMemInfo()
 {
+  scan_one( MemInfoBuf, "MemTotal", &Total );
+  scan_one( MemInfoBuf, "MemFree", &MFree );
+  scan_one( MemInfoBuf, "Buffers", &Buffers );
+  scan_one( MemInfoBuf, "Cached", &Cached );
+  scan_one( MemInfoBuf, "SwapTotal", &STotal );
+  scan_one( MemInfoBuf, "SwapFree", &SFree );
   Used = Total - MFree;
   Appl = ( Used - ( Buffers + Cached ) );