rewind stream instead of opening a new one
This commit is contained in:
parent
ac0963c608
commit
6b62079d8a
|
@ -25,8 +25,7 @@ void waybar::modules::Memory::parseMeminfo()
|
||||||
int memtotal, memfree, memavail, membuffer, memcache;
|
int memtotal, memfree, memavail, membuffer, memcache;
|
||||||
FILE* info = fopen("/proc/meminfo","r");
|
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
|
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);
|
rewind(info);
|
||||||
info = fopen("/proc/meminfo","r");
|
|
||||||
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
|
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;
|
memtotal_ = -1;
|
||||||
memfree_ = -1;
|
memfree_ = -1;
|
||||||
|
|
Loading…
Reference in New Issue