tRelease headers memory when program terminates - scribo - Email-based phlog generator
 (HTM) git clone git://git.z3bra.org/scribo.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 7f49155fea2cf3104dfa570f8a27e27bcbf111db
 (DIR) parent f39a076dbb3ce131f85784f323937f1c2ba08f67
 (HTM) Author: Willy Goiffon <dev@z3bra.org>
       Date:   Sun, 20 Sep 2020 11:31:17 +0200
       
       Release headers memory when program terminates
       
       Diffstat:
         M scribo.c                            |      13 +++++++++++++
       
       1 file changed, 13 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/scribo.c b/scribo.c
       t@@ -39,6 +39,7 @@ char * sanitize(const char *);
        FILE *pipeout(const char *, FILE *);
        char * header(struct headers *, char *);
        struct hdr * saveheader(struct headers *, char *);
       +void freeheaders(struct headers *head);
        int parseheaders(FILE *, struct headers *);
        int verifyheaders(struct headers *);
        int write_8bit(FILE *, FILE *);
       t@@ -129,6 +130,16 @@ saveheader(struct headers *head, char *line)
                return h;
        }
        
       +void
       +freeheaders(struct headers *head)
       +{
       +        struct hdr *h;
       +        while ((h = SLIST_FIRST(head))) {
       +                SLIST_REMOVE_HEAD(head, entries);
       +                free(h);
       +        }
       +}
       +
        int
        parseheaders(FILE *fp, struct headers *head)
        {
       t@@ -366,5 +377,7 @@ main(int argc, char *argv[])
        
                fclose(in);
        
       +        freeheaders(&headers);
       +
                return 0;
        }