rewind stream instead of opening a new one

pull/91/head
Robinhuett 2018-11-09 00:17:30 +01:00
parent ac0963c608
commit 6b62079d8a
1 changed files with 1 additions and 2 deletions

View File

@ -25,8 +25,7 @@ void waybar::modules::Memory::parseMeminfo()
int memtotal, memfree, memavail, membuffer, memcache;
FILE* info = fopen("/proc/meminfo","r");
if(fscanf (info, "MemTotal: %d kB MemFree: %d kB Buffers: %d kB Cached: %d kB",&memtotal, &memfree, &membuffer, &memcache) < 4) { // Old meminfo format
fclose(info);
info = fopen("/proc/meminfo","r");
rewind(info);
if(fscanf(info, "MemTotal: %d kB MemFree: %d kB MemAvailable: %d kB Buffers: %d kB Cached: %d kB",&memtotal, &memfree, &memavail, &membuffer, &memcache) < 5) { // Current meminfo format
memtotal_ = -1;
memfree_ = -1;