Diff options
Diffstat (limited to '')
-rw-r--r--source/parsing.c27
-rw-r--r--source/parsing.h5
-rw-r--r--source/shared.c24
-rw-r--r--source/shared.h3
-rw-r--r--source/ui-commit.c1
-rw-r--r--source/ui-refs.c1
-rw-r--r--source/ui-stats.c1
-rw-r--r--source/ui-summary.c1
-rw-r--r--source/ui-tag.c1
9 files changed, 30 insertions, 34 deletions
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);
+}
diff --git a/source/parsing.h b/source/parsing.h
index 755d646..c0bdebc 100644
--- a/source/parsing.h
+++ b/source/parsing.h
@@ -2,7 +2,8 @@
* Readers that turn raw git object bodies and the incoming request URL into
* the records cgit renders from. Commit and tag objects arrive as flat text,
* so the work here is splitting off the headers and re-encoding the remaining
- * free text into the page encoding.
+ * free text into the page encoding. Each record is freed beside the reader that
+ * builds it.
*/
#ifndef CGIT_PARSING_H
@@ -18,6 +19,8 @@ extern void cgit_parse_url(const char *url);
extern struct string_list *cgit_mailmap(void);
extern struct commitinfo *cgit_parse_commit(struct commit *commit);
+extern void cgit_free_commitinfo(struct commitinfo *info);
extern struct taginfo *cgit_parse_tag(struct tag *tag);
+extern void cgit_free_taginfo(struct taginfo *info);
#endif // CGIT_PARSING_H
diff --git a/source/shared.c b/source/shared.c
index e3d2e58..7538c85 100644
--- a/source/shared.c
+++ b/source/shared.c
@@ -179,17 +179,6 @@ struct cgit_repo *cgit_get_repoinfo(const char *url)
return NULL;
}
-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);
-}
-
char *cgit_trim_end(const char *str, char c)
{
size_t len;
@@ -204,19 +193,6 @@ char *cgit_trim_end(const char *str, char c)
return xstrndup(str, len);
}
-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);
-}
-
void cgit_diff_tree_cb(struct diff_queue_struct *q, struct diff_options *options UNUSED, void *data)
{
filepair_fn fn = *(filepair_fn *)data;
diff --git a/source/shared.h b/source/shared.h
index 4f015e7..4359bef 100644
--- a/source/shared.h
+++ b/source/shared.h
@@ -24,9 +24,6 @@ typedef void (*linediff_fn)(char *line, int len);
extern struct cgit_repo *cgit_add_repo(const char *url);
extern struct cgit_repo *cgit_get_repoinfo(const char *url);
-extern void cgit_free_commitinfo(struct commitinfo *info);
-extern void cgit_free_taginfo(struct taginfo *info);
-
/*
* A diff format callback that hands each filepair to the filepair_fn data
* points at. ISO C has no conversion between a function pointer and void *,
diff --git a/source/ui-commit.c b/source/ui-commit.c
index c290a2c..4882f3a 100644
--- a/source/ui-commit.c
+++ b/source/ui-commit.c
@@ -12,7 +12,6 @@
#include "filter.h"
#include "html.h"
#include "parsing.h"
-#include "shared.h"
#include "ui-commit.h"
#include "ui-diff.h"
#include "ui-log.h"
diff --git a/source/ui-refs.c b/source/ui-refs.c
index a99ba65..9bf5d2d 100644
--- a/source/ui-refs.c
+++ b/source/ui-refs.c
@@ -13,7 +13,6 @@
#include "filter.h"
#include "html.h"
#include "parsing.h"
-#include "shared.h"
#include "ui-refs.h"
#include "ui-shared.h"
diff --git a/source/ui-stats.c b/source/ui-stats.c
index 7d7b810..cab484f 100644
--- a/source/ui-stats.c
+++ b/source/ui-stats.c
@@ -9,7 +9,6 @@
#include "cgit.h"
#include "html.h"
#include "parsing.h"
-#include "shared.h"
#include "ui-shared.h"
#include "ui-stats.h"
diff --git a/source/ui-summary.c b/source/ui-summary.c
index 9972f76..8cc48bf 100644
--- a/source/ui-summary.c
+++ b/source/ui-summary.c
@@ -10,7 +10,6 @@
#include "cgit.h"
#include "filter.h"
#include "html.h"
-#include "shared.h"
#include "ui-blob.h"
#include "ui-log.h"
#include "ui-refs.h"
diff --git a/source/ui-tag.c b/source/ui-tag.c
index 1242a61..04cbb8b 100644
--- a/source/ui-tag.c
+++ b/source/ui-tag.c
@@ -13,7 +13,6 @@
#include "filter.h"
#include "html.h"
#include "parsing.h"
-#include "shared.h"
#include "ui-shared.h"
#include "ui-tag.h"