diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2017-06-15 23:15:45 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-06-16 12:41:54 -0700 |
commit | cf9f49ea4817b36e93e64909a918a912cc32c28b (patch) | |
tree | 12aecc186db45e1cd2da6fc76ce8227287f6e836 /contrib | |
parent | git-compat-util: add a FREE_AND_NULL() wrapper around free(ptr); ptr = NULL (diff) | |
download | tgif-cf9f49ea4817b36e93e64909a918a912cc32c28b.tar.xz |
coccinelle: add a rule to make "type" code use FREE_AND_NULL()
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/coccinelle/free.cocci | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/contrib/coccinelle/free.cocci b/contrib/coccinelle/free.cocci index c03ba737e5..35fb992621 100644 --- a/contrib/coccinelle/free.cocci +++ b/contrib/coccinelle/free.cocci @@ -9,3 +9,11 @@ expression E; @@ - if (!E) free(E); + +@@ +type T; +T *ptr; +@@ +- free(ptr); +- ptr = NULL; ++ FREE_AND_NULL(ptr); |