summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ball <nullspoon@oper.io>2022-07-16 17:50:08 -0600
committerAaron Ball <nullspoon@oper.io>2022-07-16 17:50:08 -0600
commitca9231bb239ca6116828f731e077c6f10da14a04 (patch)
tree65c946c3bdc87c18d485ceb4aee1e168ce8ec3f1
parente22ce3145599dceb86973ec021ad3870b83e1c86 (diff)
parent164650a73702a97c3197b82ad09d6363c16c6c52 (diff)
downloadi3cstat-ca9231bb239ca6116828f731e077c6f10da14a04.tar.gz
i3cstat-ca9231bb239ca6116828f731e077c6f10da14a04.tar.xz
Merge branch 'fix-memleak'
-rw-r--r--src/config.c11
-rw-r--r--src/config.h1
-rw-r--r--src/main.c1
3 files changed, 13 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c
index 1446c98..cced772 100644
--- a/src/config.c
+++ b/src/config.c
@@ -130,3 +130,14 @@ struct node* config_load(char* path) {
fclose(fd);
return list;
}
+
+void config_free(struct node* list) {
+ struct node* next = NULL;
+
+ while(list != NULL) {
+ next = list->next;
+ free(list->data);
+ free(list);
+ list = next;
+ }
+}
diff --git a/src/config.h b/src/config.h
index d237992..883f80d 100644
--- a/src/config.h
+++ b/src/config.h
@@ -31,3 +31,4 @@
#include "config_shell.h"
struct node* config_load(char*);
+void config_free(struct node*);
diff --git a/src/main.c b/src/main.c
index 430df4e..ffab51f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -66,6 +66,7 @@ int main(int argc, char* argv[]) {
printf("],\n");
usleep(sleeptime);
}
+ config_free(cur);
return 0;
}

Generated by cgit