From 6b62079d8a8eaf49d2d1f546c9807399a877d963 Mon Sep 17 00:00:00 2001 From: Robinhuett <5955614+Robinhuett@users.noreply.github.com> Date: Fri, 9 Nov 2018 00:17:30 +0100 Subject: [PATCH] rewind stream instead of opening a new one --- src/modules/memory.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/modules/memory.cpp b/src/modules/memory.cpp index 108380f5..97e4ab31 100644 --- a/src/modules/memory.cpp +++ b/src/modules/memory.cpp @@ -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;