aboutsummaryrefslogtreecommitdiffstats
path: root/shared.c
diff options
context:
space:
mode:
authorJason A. Donenfeld2013-03-20 20:21:25 +0100
committerJason A. Donenfeld2013-03-20 20:21:25 +0100
commit0255821e22678d4c58c809efe17bf2798835d5b9 (patch)
treed4679ff23796406648cf83ff0b98940ba844c5e1 /shared.c
parent6d8a789d61f3a682bc040f1f7f44050b1f723546 (diff)
parent59fe348deaa270434f05afc56ca8d13618af9ca9 (diff)
downloadcgit-0255821e22678d4c58c809efe17bf2798835d5b9.tar.gz
cgit-0255821e22678d4c58c809efe17bf2798835d5b9.tar.bz2
cgit-0255821e22678d4c58c809efe17bf2798835d5b9.zip
Merge branch 'wip'
Diffstat (limited to 'shared.c')
-rw-r--r--shared.c48
1 files changed, 42 insertions, 6 deletions
diff --git a/shared.c b/shared.c
index e732064..cc06930 100644
--- a/shared.c
+++ b/shared.c
@@ -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
161struct refinfo *cgit_mk_refinfo(const char *refname, const unsigned char *sha1) 161static 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
179static 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
190static 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
205void 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
179int cgit_refs_cb(const char *refname, const unsigned char *sha1, int flags, 215int 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
190void cgit_diff_tree_cb(struct diff_queue_struct *q, 226static 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)
224char *diffbuf = NULL; 260char *diffbuf = NULL;
225int buflen = 0; 261int buflen = 0;
226 262
227int filediff_cb(void *priv, mmbuffer_t *mb, int nbuf) 263static 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
464int is_token_char(char c) 500static 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 */
471char *expand_macro(char *name, int maxlength) 507static char *expand_macro(char *name, int maxlength)
472{ 508{
473 char *value; 509 char *value;
474 int len; 510 int len;