diff options
author | Aaron Ball <nullspoon@oper.io> | 2022-07-16 17:50:08 -0600 |
---|---|---|
committer | Aaron Ball <nullspoon@oper.io> | 2022-07-16 17:50:08 -0600 |
commit | ca9231bb239ca6116828f731e077c6f10da14a04 (patch) | |
tree | 65c946c3bdc87c18d485ceb4aee1e168ce8ec3f1 | |
parent | e22ce3145599dceb86973ec021ad3870b83e1c86 (diff) | |
parent | 164650a73702a97c3197b82ad09d6363c16c6c52 (diff) | |
download | i3cstat-ca9231bb239ca6116828f731e077c6f10da14a04.tar.gz i3cstat-ca9231bb239ca6116828f731e077c6f10da14a04.tar.xz |
Merge branch 'fix-memleak'
-rw-r--r-- | src/config.c | 11 | ||||
-rw-r--r-- | src/config.h | 1 | ||||
-rw-r--r-- | src/main.c | 1 |
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*); @@ -66,6 +66,7 @@ int main(int argc, char* argv[]) { printf("],\n"); usleep(sleeptime); } + config_free(cur); return 0; } |