From b67acafd615ae705a3e3682f87f35027789ddda5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Sat, 18 Sep 2021 10:42:51 +0200 Subject: Free database structs after use --- README | 8 ++++---- ctl.c | 3 +++ t/front.t | 3 ++- t/post.t | 3 ++- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/README b/README index 2086996..3b17846 100644 --- a/README +++ b/README @@ -9,7 +9,7 @@ It is also rather small: wc -l *.c *.h */*.t */*.lex 96 cforum.c - 96 ctl.c + 99 ctl.c 133 db.c 10 err.c 106 query.c @@ -20,9 +20,9 @@ It is also rather small: 2 site.h 3 t/err.t 1 t/foot.t - 13 t/front.t + 14 t/front.t 6 t/head.t - 27 t/post.t + 28 t/post.t 2 t/user.t 87 mktpl/mktpl.lex - 636 total + 641 total diff --git a/ctl.c b/ctl.c index 2d7f41a..757d159 100644 --- a/ctl.c +++ b/ctl.c @@ -31,6 +31,7 @@ showatt(id) printf("Content-Type: %s\n\n", att->mime); printf("%.*s", att->bytes, att->data); + free(att); } void @@ -77,6 +78,8 @@ showpost(int id) title = site.name; printf("Content-Type: text/html\n\n"); #include "t/post.tc" + free(user); + free(post); } void diff --git a/t/front.t b/t/front.t index fd9f46c..a12d712 100644 --- a/t/front.t +++ b/t/front.t @@ -9,6 +9,7 @@ user); %>"><%= user->name %> <% printdate(post->created); %> - <% } %> + <% free(post); + } %> <% #include "foot.tc" %> \ No newline at end of file diff --git a/t/post.t b/t/post.t index b1cbe99..1e3d360 100644 --- a/t/post.t +++ b/t/post.t @@ -22,7 +22,8 @@ <%= att->mime %> <%= att->description %> - <% }while(att = nextatt(stmt)); %> + <% free(att); + }while(att = nextatt(stmt)); %> <% } %> <% #include "foot.tc" %> \ No newline at end of file -- cgit v1.2.3