1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-11-06 01:03:02 +01:00
git/contrib/coccinelle/free.cocci
Ævar Arnfjörð Bjarmason 1b83d1251e coccinelle: add a rule to make "expression" code use FREE_AND_NULL()
A follow-up to the existing "type" rule added in an earlier
change. This catches some occurrences that are missed by the previous
rule.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-06-16 12:44:04 -07:00

26 lines
218 B
Text

@@
expression E;
@@
- if (E)
free(E);
@@
expression E;
@@
- if (!E)
free(E);
@@
type T;
T *ptr;
@@
- free(ptr);
- ptr = NULL;
+ FREE_AND_NULL(ptr);
@@
expression E;
@@
- free(E);
- E = NULL;
+ FREE_AND_NULL(E);