Skip to content

Commit

Permalink
apply: rename free_patch() to free_patch_list()
Browse files Browse the repository at this point in the history
As that is the only logical name for a function that walks a list
and frees each element on it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Mar 27, 2012
1 parent 6fe5390 commit a604dde
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions builtin/apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,24 @@ struct patch {

static void free_patch(struct patch *patch)
{
while (patch) {
struct patch *patch_next = patch->next;
struct fragment *fragment = patch->fragments;

while (fragment) {
struct fragment *fragment_next = fragment->next;
if (fragment->patch != NULL && fragment->free_patch)
free((char *)fragment->patch);
free(fragment);
fragment = fragment_next;
}
free(patch);
patch = patch_next;
struct fragment *fragment = patch->fragments;

while (fragment) {
struct fragment *fragment_next = fragment->next;
if (fragment->patch != NULL && fragment->free_patch)
free((char *)fragment->patch);
free(fragment);
fragment = fragment_next;
}
free(patch);
}

static void free_patch_list(struct patch *list)
{
while (list) {
struct patch *next = list->next;
free_patch(list);
list = next;
}
}

Expand Down Expand Up @@ -3771,7 +3776,7 @@ static int apply_patch(int fd, const char *filename, int options)
if (summary)
summary_patch_list(list);

free_patch(list);
free_patch_list(list);
strbuf_release(&buf);
return 0;
}
Expand Down

0 comments on commit a604dde

Please sign in to comment.