diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2013-03-21 04:21:25 (JST) |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2013-03-21 04:21:25 (JST) |
commit | 0255821e22678d4c58c809efe17bf2798835d5b9 (patch) | |
tree | d4679ff23796406648cf83ff0b98940ba844c5e1 /shared.c | |
parent | 6d8a789d61f3a682bc040f1f7f44050b1f723546 (diff) | |
parent | 59fe348deaa270434f05afc56ca8d13618af9ca9 (diff) | |
download | cgit-0255821e22678d4c58c809efe17bf2798835d5b9.zip cgit-0255821e22678d4c58c809efe17bf2798835d5b9.tar.gz |
Merge branch 'wip'
Diffstat (limited to 'shared.c')
-rw-r--r-- | shared.c | 48 |
1 files changed, 42 insertions, 6 deletions
@@ -158,7 +158,7 @@ void cgit_add_ref(struct reflist *list, struct refinfo *ref) | |||
158 | list->refs[list->count++] = ref; | 158 | list->refs[list->count++] = ref; |
159 | } | 159 | } |
160 | 160 | ||
161 | struct refinfo *cgit_mk_refinfo(const char *refname, const unsigned char *sha1) | 161 | static struct refinfo *cgit_mk_refinfo(const char *refname, const unsigned char *sha1) |
162 | { | 162 | { |
163 | struct refinfo *ref; | 163 | struct refinfo *ref; |
164 | 164 | ||
@@ -176,6 +176,42 @@ struct refinfo *cgit_mk_refinfo(const char *refname, const unsigned char *sha1) | |||
176 | return ref; | 176 | return ref; |
177 | } | 177 | } |
178 | 178 | ||
179 | static void cgit_free_taginfo(struct taginfo *tag) | ||
180 | { | ||
181 | if (tag->tagger) | ||
182 | free(tag->tagger); | ||
183 | if (tag->tagger_email) | ||
184 | free(tag->tagger_email); | ||
185 | if (tag->msg) | ||
186 | free(tag->msg); | ||
187 | free(tag); | ||
188 | } | ||
189 | |||
190 | static void cgit_free_refinfo(struct refinfo *ref) | ||
191 | { | ||
192 | if (ref->refname) | ||
193 | free((char *)ref->refname); | ||
194 | switch (ref->object->type) { | ||
195 | case OBJ_TAG: | ||
196 | cgit_free_taginfo(ref->tag); | ||
197 | break; | ||
198 | case OBJ_COMMIT: | ||
199 | cgit_free_commitinfo(ref->commit); | ||
200 | break; | ||
201 | } | ||
202 | free(ref); | ||
203 | } | ||
204 | |||
205 | void cgit_free_reflist_inner(struct reflist *list) | ||
206 | { | ||
207 | int i; | ||
208 | |||
209 | for (i = 0; i < list->count; i++) { | ||
210 | cgit_free_refinfo(list->refs[i]); | ||
211 | } | ||
212 | free(list->refs); | ||
213 | } | ||
214 | |||
179 | int cgit_refs_cb(const char *refname, const unsigned char *sha1, int flags, | 215 | int cgit_refs_cb(const char *refname, const unsigned char *sha1, int flags, |
180 | void *cb_data) | 216 | void *cb_data) |
181 | { | 217 | { |
@@ -187,8 +223,8 @@ int cgit_refs_cb(const char *refname, const unsigned char *sha1, int flags, | |||
187 | return 0; | 223 | return 0; |
188 | } | 224 | } |
189 | 225 | ||
190 | void cgit_diff_tree_cb(struct diff_queue_struct *q, | 226 | static void cgit_diff_tree_cb(struct diff_queue_struct *q, |
191 | struct diff_options *options, void *data) | 227 | struct diff_options *options, void *data) |
192 | { | 228 | { |
193 | int i; | 229 | int i; |
194 | 230 | ||
@@ -224,7 +260,7 @@ static int load_mmfile(mmfile_t *file, const unsigned char *sha1) | |||
224 | char *diffbuf = NULL; | 260 | char *diffbuf = NULL; |
225 | int buflen = 0; | 261 | int buflen = 0; |
226 | 262 | ||
227 | int filediff_cb(void *priv, mmbuffer_t *mb, int nbuf) | 263 | static int filediff_cb(void *priv, mmbuffer_t *mb, int nbuf) |
228 | { | 264 | { |
229 | int i; | 265 | int i; |
230 | 266 | ||
@@ -461,14 +497,14 @@ int readfile(const char *path, char **buf, size_t *size) | |||
461 | return (*size == st.st_size ? 0 : e); | 497 | return (*size == st.st_size ? 0 : e); |
462 | } | 498 | } |
463 | 499 | ||
464 | int is_token_char(char c) | 500 | static int is_token_char(char c) |
465 | { | 501 | { |
466 | return isalnum(c) || c == '_'; | 502 | return isalnum(c) || c == '_'; |
467 | } | 503 | } |
468 | 504 | ||
469 | /* Replace name with getenv(name), return pointer to zero-terminating char | 505 | /* Replace name with getenv(name), return pointer to zero-terminating char |
470 | */ | 506 | */ |
471 | char *expand_macro(char *name, int maxlength) | 507 | static char *expand_macro(char *name, int maxlength) |
472 | { | 508 | { |
473 | char *value; | 509 | char *value; |
474 | int len; | 510 | int len; |