Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.zx2c4.com/cgit.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cgit.h1
-rw-r--r--shared.c36
-rw-r--r--ui-refs.c4
3 files changed, 41 insertions, 0 deletions
diff --git a/cgit.h b/cgit.h
index c655bd8..ed5cf14 100644
--- a/cgit.h
+++ b/cgit.h
@@ -304,6 +304,7 @@ extern char *strlpart(char *txt, int maxlen);
extern char *strrpart(char *txt, int maxlen);
extern void cgit_add_ref(struct reflist *list, struct refinfo *ref);
+extern void cgit_free_reflist_inner(struct reflist *list);
extern int cgit_refs_cb(const char *refname, const unsigned char *sha1,
int flags, void *cb_data);
diff --git a/shared.c b/shared.c
index 124d079..cc06930 100644
--- a/shared.c
+++ b/shared.c
@@ -176,6 +176,42 @@ static struct refinfo *cgit_mk_refinfo(const char *refname, const unsigned char
return ref;
}
+static void cgit_free_taginfo(struct taginfo *tag)
+{
+ if (tag->tagger)
+ free(tag->tagger);
+ if (tag->tagger_email)
+ free(tag->tagger_email);
+ if (tag->msg)
+ free(tag->msg);
+ free(tag);
+}
+
+static void cgit_free_refinfo(struct refinfo *ref)
+{
+ if (ref->refname)
+ free((char *)ref->refname);
+ switch (ref->object->type) {
+ case OBJ_TAG:
+ cgit_free_taginfo(ref->tag);
+ break;
+ case OBJ_COMMIT:
+ cgit_free_commitinfo(ref->commit);
+ break;
+ }
+ free(ref);
+}
+
+void cgit_free_reflist_inner(struct reflist *list)
+{
+ int i;
+
+ for (i = 0; i < list->count; i++) {
+ cgit_free_refinfo(list->refs[i]);
+ }
+ free(list->refs);
+}
+
int cgit_refs_cb(const char *refname, const unsigned char *sha1, int flags,
void *cb_data)
{
diff --git a/ui-refs.c b/ui-refs.c
index ce06b08..4a9b8d3 100644
--- a/ui-refs.c
+++ b/ui-refs.c
@@ -205,6 +205,8 @@ void cgit_print_branches(int maxcount)
if (maxcount < list.count)
print_refs_link("heads");
+
+ cgit_free_reflist_inner(&list);
}
void cgit_print_tags(int maxcount)
@@ -229,6 +231,8 @@ void cgit_print_tags(int maxcount)
if (maxcount < list.count)
print_refs_link("tags");
+
+ cgit_free_reflist_inner(&list);
}
void cgit_print_refs()