diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2017-06-15 23:15:49 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-06-16 12:44:09 -0700 |
commit | 88ce3ef636b1385e861ec0e9e2155248b999b032 (patch) | |
tree | 0da315e544f734755c717c04852b2c44ac3345d3 /builtin | |
parent | coccinelle: make use of the "expression" FREE_AND_NULL() rule (diff) | |
download | tgif-88ce3ef636b1385e861ec0e9e2155248b999b032.tar.xz |
*.[ch] refactoring: make use of the FREE_AND_NULL() macro
Replace occurrences of `free(ptr); ptr = NULL` which weren't caught by
the coccinelle rule. These fall into two categories:
- free/NULL assignments one after the other which coccinelle all put
on one line, which is functionally equivalent code, but very ugly.
- manually spotted occurrences where the NULL assignment isn't right
after the free() call.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/am.c | 15 | ||||
-rw-r--r-- | builtin/worktree.c | 6 |
2 files changed, 6 insertions, 15 deletions
diff --git a/builtin/am.c b/builtin/am.c index 138fb98537..80368b6fe6 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -1072,17 +1072,10 @@ static void am_next(struct am_state *state) { struct object_id head; - free(state->author_name); - state->author_name = NULL; - - free(state->author_email); - state->author_email = NULL; - - free(state->author_date); - state->author_date = NULL; - - free(state->msg); - state->msg = NULL; + FREE_AND_NULL(state->author_name); + FREE_AND_NULL(state->author_email); + FREE_AND_NULL(state->author_date); + FREE_AND_NULL(state->msg); state->msg_len = 0; unlink(am_path(state, "author-script")); diff --git a/builtin/worktree.c b/builtin/worktree.c index 793306ea51..41d1c007a4 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -299,10 +299,8 @@ static int add_worktree(const char *path, const char *refname, } is_junk = 0; - free(junk_work_tree); - free(junk_git_dir); - junk_work_tree = NULL; - junk_git_dir = NULL; + FREE_AND_NULL(junk_work_tree); + FREE_AND_NULL(junk_git_dir); done: if (ret || !opts->keep_locked) { |