@@ -455,11 +455,8 @@ struct commit_list *copy_commit_list(struct commit_list *list)
455455
456456void free_commit_list (struct commit_list * list )
457457{
458- while (list ) {
459- struct commit_list * temp = list ;
460- list = temp -> next ;
461- free (temp );
462- }
458+ while (list )
459+ pop_commit (& list );
463460}
464461
465462struct commit_list * commit_list_insert_by_date (struct commit * item , struct commit_list * * list )
@@ -505,12 +502,8 @@ void commit_list_sort_by_date(struct commit_list **list)
505502struct commit * pop_most_recent_commit (struct commit_list * * list ,
506503 unsigned int mark )
507504{
508- struct commit * ret = ( * list )-> item ;
505+ struct commit * ret = pop_commit ( list );
509506 struct commit_list * parents = ret -> parents ;
510- struct commit_list * old = * list ;
511-
512- * list = (* list )-> next ;
513- free (old );
514507
515508 while (parents ) {
516509 struct commit * commit = parents -> item ;
@@ -861,11 +854,9 @@ static struct commit_list *merge_bases_many(struct commit *one, int n, struct co
861854 list = paint_down_to_common (one , n , twos );
862855
863856 while (list ) {
864- struct commit_list * next = list -> next ;
865- if (!(list -> item -> object .flags & STALE ))
866- commit_list_insert_by_date (list -> item , & result );
867- free (list );
868- list = next ;
857+ struct commit * commit = pop_commit (& list );
858+ if (!(commit -> object .flags & STALE ))
859+ commit_list_insert_by_date (commit , & result );
869860 }
870861 return result ;
871862}
@@ -1546,13 +1537,9 @@ int commit_tree_extended(const char *msg, size_t msg_len,
15461537 * if everything else stays the same.
15471538 */
15481539 while (parents ) {
1549- struct commit_list * next = parents -> next ;
1550- struct commit * parent = parents -> item ;
1551-
1540+ struct commit * parent = pop_commit (& parents );
15521541 strbuf_addf (& buffer , "parent %s\n" ,
15531542 sha1_to_hex (parent -> object .sha1 ));
1554- free (parents );
1555- parents = next ;
15561543 }
15571544
15581545 /* Person/date information */
0 commit comments