diff options
author | Junio C Hamano <gitster@pobox.com> | 2012-03-27 15:10:01 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-03-27 15:39:31 -0700 |
commit | a604ddef737c79f4df9a943ff316e87b7c8a1de8 (patch) | |
tree | 13ab6ce49306405cc7527370b3b7b8ac0e08737c | |
parent | apply: do not leak patches and fragments (diff) | |
download | tgif-a604ddef737c79f4df9a943ff316e87b7c8a1de8.tar.xz |
apply: rename free_patch() to free_patch_list()
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>
-rw-r--r-- | builtin/apply.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/builtin/apply.c b/builtin/apply.c index 427c2634d7..aff1d9f75d 100644 --- a/builtin/apply.c +++ b/builtin/apply.c @@ -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; } } @@ -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; } |