author | Lars Hjemli <hjemli@gmail.com> | 2006-12-16 13:58:20 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2006-12-16 13:58:20 (UTC) |
commit | aaa24bdd30303128bded8487cd9f63b54c3b8dcd (patch) (unidiff) | |
tree | 0fd8b32643c205d819f98a827eca3e78fad21bfa | |
parent | fa82b03e05366e3c6ca1b74c8c83d6e00e0ef1e6 (diff) | |
download | cgit-aaa24bdd30303128bded8487cd9f63b54c3b8dcd.zip cgit-aaa24bdd30303128bded8487cd9f63b54c3b8dcd.tar.gz cgit-aaa24bdd30303128bded8487cd9f63b54c3b8dcd.tar.bz2 |
Add cgit_free_commitinfo() and use where needed
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | cgit.h | 2 | ||||
-rw-r--r-- | shared.c | 10 | ||||
-rw-r--r-- | ui-commit.c | 5 | ||||
-rw-r--r-- | ui-log.c | 5 | ||||
-rw-r--r-- | ui-summary.c | 1 |
5 files changed, 15 insertions, 8 deletions
@@ -56,24 +56,26 @@ extern char *cgit_querystring; | |||
56 | extern char *cgit_query_repo; | 56 | extern char *cgit_query_repo; |
57 | extern char *cgit_query_page; | 57 | extern char *cgit_query_page; |
58 | extern char *cgit_query_head; | 58 | extern char *cgit_query_head; |
59 | extern char *cgit_query_sha1; | 59 | extern char *cgit_query_sha1; |
60 | extern int cgit_query_ofs; | 60 | extern int cgit_query_ofs; |
61 | 61 | ||
62 | extern int htmlfd; | 62 | extern int htmlfd; |
63 | 63 | ||
64 | extern void cgit_global_config_cb(const char *name, const char *value); | 64 | extern void cgit_global_config_cb(const char *name, const char *value); |
65 | extern void cgit_repo_config_cb(const char *name, const char *value); | 65 | extern void cgit_repo_config_cb(const char *name, const char *value); |
66 | extern void cgit_querystring_cb(const char *name, const char *value); | 66 | extern void cgit_querystring_cb(const char *name, const char *value); |
67 | 67 | ||
68 | extern void *cgit_free_commitinfo(struct commitinfo *info); | ||
69 | |||
68 | extern char *fmt(const char *format,...); | 70 | extern char *fmt(const char *format,...); |
69 | 71 | ||
70 | extern void html(const char *txt); | 72 | extern void html(const char *txt); |
71 | extern void htmlf(const char *format,...); | 73 | extern void htmlf(const char *format,...); |
72 | extern void html_txt(char *txt); | 74 | extern void html_txt(char *txt); |
73 | extern void html_attr(char *txt); | 75 | extern void html_attr(char *txt); |
74 | extern void html_link_open(char *url, char *title, char *class); | 76 | extern void html_link_open(char *url, char *title, char *class); |
75 | extern void html_link_close(void); | 77 | extern void html_link_close(void); |
76 | 78 | ||
77 | extern int cgit_read_config(const char *filename, configfn fn); | 79 | extern int cgit_read_config(const char *filename, configfn fn); |
78 | extern int cgit_parse_query(char *txt, configfn fn); | 80 | extern int cgit_parse_query(char *txt, configfn fn); |
79 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); | 81 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); |
@@ -79,12 +79,22 @@ void cgit_querystring_cb(const char *name, const char *value) | |||
79 | cgit_query_page = xstrdup(value); | 79 | cgit_query_page = xstrdup(value); |
80 | } else if (!strcmp(name, "h")) { | 80 | } else if (!strcmp(name, "h")) { |
81 | cgit_query_head = xstrdup(value); | 81 | cgit_query_head = xstrdup(value); |
82 | cgit_query_has_symref = 1; | 82 | cgit_query_has_symref = 1; |
83 | } else if (!strcmp(name, "id")) { | 83 | } else if (!strcmp(name, "id")) { |
84 | cgit_query_sha1 = xstrdup(value); | 84 | cgit_query_sha1 = xstrdup(value); |
85 | cgit_query_has_sha1 = 1; | 85 | cgit_query_has_sha1 = 1; |
86 | } else if (!strcmp(name, "ofs")) { | 86 | } else if (!strcmp(name, "ofs")) { |
87 | cgit_query_ofs = atoi(value); | 87 | cgit_query_ofs = atoi(value); |
88 | } | 88 | } |
89 | } | 89 | } |
90 | 90 | ||
91 | void *cgit_free_commitinfo(struct commitinfo *info) | ||
92 | { | ||
93 | free(info->author); | ||
94 | free(info->author_email); | ||
95 | free(info->committer); | ||
96 | free(info->committer_email); | ||
97 | free(info->subject); | ||
98 | free(info); | ||
99 | return NULL; | ||
100 | } | ||
diff --git a/ui-commit.c b/ui-commit.c index b441e14..f654208 100644 --- a/ui-commit.c +++ b/ui-commit.c | |||
@@ -52,17 +52,14 @@ void cgit_print_commit(const char *hex) | |||
52 | html("<tr><th>parent</th><td colspan='2' class='sha1'><a href='"); | 52 | html("<tr><th>parent</th><td colspan='2' class='sha1'><a href='"); |
53 | html_attr(cgit_pageurl(cgit_query_repo, "commit", fmt("id=%s", sha1_to_hex(p->item->object.sha1)))); | 53 | html_attr(cgit_pageurl(cgit_query_repo, "commit", fmt("id=%s", sha1_to_hex(p->item->object.sha1)))); |
54 | htmlf("'>%s</a></td></tr>\n", | 54 | htmlf("'>%s</a></td></tr>\n", |
55 | sha1_to_hex(p->item->object.sha1)); | 55 | sha1_to_hex(p->item->object.sha1)); |
56 | } | 56 | } |
57 | html("</table>\n"); | 57 | html("</table>\n"); |
58 | html("<div class='commit-subject'>"); | 58 | html("<div class='commit-subject'>"); |
59 | html_txt(info->subject); | 59 | html_txt(info->subject); |
60 | html("</div>"); | 60 | html("</div>"); |
61 | html("<div class='commit-msg'>"); | 61 | html("<div class='commit-msg'>"); |
62 | html_txt(info->msg); | 62 | html_txt(info->msg); |
63 | html("</div>"); | 63 | html("</div>"); |
64 | free(info->author); | 64 | cgit_free_commitinfo(info); |
65 | free(info->committer); | ||
66 | free(info->subject); | ||
67 | free(info); | ||
68 | } | 65 | } |
@@ -19,28 +19,25 @@ void print_commit(struct commit *commit) | |||
19 | html("<tr><td>"); | 19 | html("<tr><td>"); |
20 | strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", time); | 20 | strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", time); |
21 | html_txt(buf); | 21 | html_txt(buf); |
22 | html("</td><td>"); | 22 | html("</td><td>"); |
23 | char *qry = fmt("id=%s", sha1_to_hex(commit->object.sha1)); | 23 | char *qry = fmt("id=%s", sha1_to_hex(commit->object.sha1)); |
24 | char *url = cgit_pageurl(cgit_query_repo, "commit", qry); | 24 | char *url = cgit_pageurl(cgit_query_repo, "commit", qry); |
25 | html_link_open(url, NULL, NULL); | 25 | html_link_open(url, NULL, NULL); |
26 | html_txt(info->subject); | 26 | html_txt(info->subject); |
27 | html_link_close(); | 27 | html_link_close(); |
28 | html("</td><td>"); | 28 | html("</td><td>"); |
29 | html_txt(info->author); | 29 | html_txt(info->author); |
30 | html("</td></tr>\n"); | 30 | html("</td></tr>\n"); |
31 | free(info->author); | 31 | cgit_free_commitinfo(info); |
32 | free(info->committer); | ||
33 | free(info->subject); | ||
34 | free(info); | ||
35 | } | 32 | } |
36 | 33 | ||
37 | 34 | ||
38 | void cgit_print_log(const char *tip, int ofs, int cnt) | 35 | void cgit_print_log(const char *tip, int ofs, int cnt) |
39 | { | 36 | { |
40 | struct rev_info rev; | 37 | struct rev_info rev; |
41 | struct commit *commit; | 38 | struct commit *commit; |
42 | const char *argv[2] = {NULL, tip}; | 39 | const char *argv[2] = {NULL, tip}; |
43 | int i; | 40 | int i; |
44 | 41 | ||
45 | init_revisions(&rev, NULL); | 42 | init_revisions(&rev, NULL); |
46 | rev.abbrev = DEFAULT_ABBREV; | 43 | rev.abbrev = DEFAULT_ABBREV; |
diff --git a/ui-summary.c b/ui-summary.c index 8ff3642..5ddeee3 100644 --- a/ui-summary.c +++ b/ui-summary.c | |||
@@ -26,24 +26,25 @@ static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1, | |||
26 | html_txt(buf); | 26 | html_txt(buf); |
27 | html_link_close(); | 27 | html_link_close(); |
28 | html("</td><td>"); | 28 | html("</td><td>"); |
29 | cgit_print_date(commit->date); | 29 | cgit_print_date(commit->date); |
30 | html("</td><td>"); | 30 | html("</td><td>"); |
31 | url = cgit_pageurl(cgit_query_repo, "commit", fmt("id=%s", sha1_to_hex(sha1))); | 31 | url = cgit_pageurl(cgit_query_repo, "commit", fmt("id=%s", sha1_to_hex(sha1))); |
32 | html_link_open(url, NULL, NULL); | 32 | html_link_open(url, NULL, NULL); |
33 | html_txt(info->subject); | 33 | html_txt(info->subject); |
34 | html_link_close(); | 34 | html_link_close(); |
35 | html("</td><td>"); | 35 | html("</td><td>"); |
36 | html_txt(info->author); | 36 | html_txt(info->author); |
37 | html("</td></tr>\n"); | 37 | html("</td></tr>\n"); |
38 | cgit_free_commitinfo(info); | ||
38 | } else { | 39 | } else { |
39 | html("<tr><td>"); | 40 | html("<tr><td>"); |
40 | html_txt(buf); | 41 | html_txt(buf); |
41 | html("</td><td>"); | 42 | html("</td><td>"); |
42 | htmlf("*** bad ref %s", sha1_to_hex(sha1)); | 43 | htmlf("*** bad ref %s", sha1_to_hex(sha1)); |
43 | html("</td></tr>\n"); | 44 | html("</td></tr>\n"); |
44 | } | 45 | } |
45 | return 0; | 46 | return 0; |
46 | } | 47 | } |
47 | 48 | ||
48 | static void cgit_print_branches() | 49 | static void cgit_print_branches() |
49 | { | 50 | { |