summaryrefslogtreecommitdiff
path: root/contrib/coccinelle/free.cocci
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2017-06-15 23:15:45 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-06-16 19:41:54 (GMT)
commitcf9f49ea4817b36e93e64909a918a912cc32c28b (patch)
tree12aecc186db45e1cd2da6fc76ce8227287f6e836 /contrib/coccinelle/free.cocci
parent481df65f4f72582369eea8d002070c5dff38f8e6 (diff)
downloadgit-cf9f49ea4817b36e93e64909a918a912cc32c28b.zip
git-cf9f49ea4817b36e93e64909a918a912cc32c28b.tar.gz
git-cf9f49ea4817b36e93e64909a918a912cc32c28b.tar.bz2
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/coccinelle/free.cocci')
-rw-r--r--contrib/coccinelle/free.cocci8
1 files changed, 8 insertions, 0 deletions
diff --git a/contrib/coccinelle/free.cocci b/contrib/coccinelle/free.cocci
index c03ba73..35fb992 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);