Add cgit_free_commitinfo() and use where needed

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
This commit is contained in:
Lars Hjemli 2006-12-16 14:58:20 +01:00
parent fa82b03e05
commit aaa24bdd30
5 changed files with 15 additions and 8 deletions

2
cgit.h
View File

@ -65,6 +65,8 @@ extern void cgit_global_config_cb(const char *name, const char *value);
extern void cgit_repo_config_cb(const char *name, const char *value); extern void cgit_repo_config_cb(const char *name, const char *value);
extern void cgit_querystring_cb(const char *name, const char *value); extern void cgit_querystring_cb(const char *name, const char *value);
extern void *cgit_free_commitinfo(struct commitinfo *info);
extern char *fmt(const char *format,...); extern char *fmt(const char *format,...);
extern void html(const char *txt); extern void html(const char *txt);

View File

@ -88,3 +88,13 @@ void cgit_querystring_cb(const char *name, const char *value)
} }
} }
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);
return NULL;
}

View File

@ -61,8 +61,5 @@ void cgit_print_commit(const char *hex)
html("<div class='commit-msg'>"); html("<div class='commit-msg'>");
html_txt(info->msg); html_txt(info->msg);
html("</div>"); html("</div>");
free(info->author); cgit_free_commitinfo(info);
free(info->committer);
free(info->subject);
free(info);
} }

View File

@ -28,10 +28,7 @@ void print_commit(struct commit *commit)
html("</td><td>"); html("</td><td>");
html_txt(info->author); html_txt(info->author);
html("</td></tr>\n"); html("</td></tr>\n");
free(info->author); cgit_free_commitinfo(info);
free(info->committer);
free(info->subject);
free(info);
} }

View File

@ -35,6 +35,7 @@ static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1,
html("</td><td>"); html("</td><td>");
html_txt(info->author); html_txt(info->author);
html("</td></tr>\n"); html("</td></tr>\n");
cgit_free_commitinfo(info);
} else { } else {
html("<tr><td>"); html("<tr><td>");
html_txt(buf); html_txt(buf);