Skip to content

Commit

Permalink
Get rid of annoying memleaks
Browse files Browse the repository at this point in the history
  • Loading branch information
henkmet committed Jun 10, 2024
1 parent 73ac7a5 commit 45289fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Binary file modified dwmbar
Binary file not shown.
10 changes: 9 additions & 1 deletion dwmbar.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ smprintf(char *fmt, ...) {
ret = malloc(++len);
if(ret == NULL) {
perror("malloc");
exit(EXIT_FAILURE);
exit(1);
}

va_start(fmtargs, fmt);
Expand Down Expand Up @@ -138,6 +138,7 @@ char *get_mpd() {
title = smprintf("%s",mpd_song_get_uri(song));

if (strcmp(title, "http://streams.greenhost.nl:8080/live") == 0) {
free((char*)title);
title = smprintf("%s", "Concertzender");
}
else {
Expand All @@ -146,6 +147,7 @@ char *get_mpd() {
deeltitel = smprintf("%s",token);
token = strtok(NULL,"/");
}
free((char*)title);
title = smprintf("%s %2d:%.2d/%2d:%.2d",
strtok(deeltitel,"."),
elapsed/60, elapsed%60,
Expand Down Expand Up @@ -179,6 +181,9 @@ char *get_mpd() {
}
else {
res = smprintf("%s", "Geen gegevens3");
if (song!=NULL) {mpd_song_free(song);}
mpd_response_finish(con);
mpd_connection_free(con);
free((char*)title);
free((char*)deeltitel);
return res;
Expand Down Expand Up @@ -218,6 +223,9 @@ int main(void) {
snprintf(status, 200, "%s | %s | %s", mpd, nowplaying, datetime);
}
setstatus(status);
free(datetime);
free(nowplaying);
free(mpd);
}

free(status);
Expand Down

0 comments on commit 45289fd

Please sign in to comment.