summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Marcher <info@nulltime.net>2016-03-09 07:45:51 +0100
committerAaron Marcher <info@nulltime.net>2016-03-09 07:45:51 +0100
commit16d01e8ded5baf47c18fdc7b093abdfc277e6961 (patch)
tree7330bc3c41ddf46372cbd943f9871e3688499a11
parent526955ecda819d3471e04bef63df802edbdec63f (diff)
parent12521e4e10cbfadc2fd42d32de101652490bf5b3 (diff)
Merge pull request #2 from pfannkuchengesicht/master
fixed some memory leaks
-rw-r--r--config.def.h2
-rw-r--r--slstatus.c24
2 files changed, 24 insertions, 2 deletions
diff --git a/config.def.h b/config.def.h
index b92a20d..e4f0ffd 100644
--- a/config.def.h
+++ b/config.def.h
@@ -19,4 +19,4 @@ static const char timeformat[] = "%y-%m-%d %H:%M:%S";
/* statusbar */
#define FORMATSTRING "wifi %4s | bat %4s | cpu %4s %3s | ram %3s | vol %4s | %3s"
-#define ARGUMENTS wifi_signal(), battery(), cpu_usage(), cpu_temperature(), ram_usage(), volume(), datetime()
+#define ARGUMENTS pWifi_signal, pBattery, pCpu_usage, pCpu_temperature, pRam_usage, pVolume, pDatetime
diff --git a/slstatus.c b/slstatus.c
index 6ca36e0..cb6282f 100644
--- a/slstatus.c
+++ b/slstatus.c
@@ -247,7 +247,7 @@ volume()
/* return the string (mute) */
if (!mute)
- return "mute";
+ return smprintf("mute");
else
return smprintf("%d%%", (vol * 100) / max);
}
@@ -322,10 +322,32 @@ main()
exit(1);
}
+ char *pWifi_signal = NULL;
+ char *pBattery = NULL;
+ char *pCpu_usage = NULL;
+ char *pCpu_temperature = NULL;
+ char *pRam_usage = NULL;
+ char *pVolume = NULL;
+ char *pDatetime = NULL;
+
/* return status every second */
for (;;) {
+ pWifi_signal = wifi_signal();
+ pBattery = battery();
+ pCpu_usage = cpu_usage();
+ pCpu_temperature = cpu_temperature();
+ pRam_usage = ram_usage();
+ pVolume = volume();
+ pDatetime = datetime();
sprintf(status, FORMATSTRING, ARGUMENTS);
setstatus(status);
+ free(pWifi_signal);
+ free(pBattery);
+ free(pCpu_usage);
+ free(pCpu_temperature);
+ free(pRam_usage);
+ free(pVolume);
+ free(pDatetime);
}
/* close display */