From c6dd4566c66ea86294b854717a50acbe8b04233e Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 31 Oct 2026 14:32:28 -0700 Subject: Free commit and tag records beside their parsers With the frees gone from shared.h, five page files need nothing else from it, so they stop including it. --- source/parsing.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'source/parsing.c') diff --git a/source/parsing.c b/source/parsing.c index 5b6ea57..f684241 100644 --- a/source/parsing.c +++ b/source/parsing.c @@ -4,7 +4,8 @@ * the request path settles which repository and which page the request works * on. Commit and tag objects arrive as header lines, a blank line, and then * the message, so the readers here walk the headers, copy out the fields the - * pages need, and re-encode the message into the page encoding. + * pages need, and re-encode the message into the page encoding. The records + * they return are freed here too. */ #define USE_THE_REPOSITORY_VARIABLE @@ -233,6 +234,17 @@ struct commitinfo *cgit_parse_commit(struct commit *commit) return info; } +void cgit_free_commitinfo(struct commitinfo *info) +{ + free(info->author); + free(info->author_email); + free(info->committer); + free(info->committer_email); + free(info->subject); + free(info->msg); + free(info); +} + struct taginfo *cgit_parse_tag(struct tag *tag) { void *data; @@ -268,3 +280,16 @@ cleanup: free(data); return info; } + +void cgit_free_taginfo(struct taginfo *info) +{ + // NULL is accepted because cgit_parse_tag returns it for a tag object + // that cannot be read, and a ref left holding that still gets freed + // along with the rest of its list. + if (!info) + return; + free(info->tagger); + free(info->tagger_email); + free(info->msg); + free(info); +} -- cgit