Re: [PATCH v3 0/2] Add a FREE_AND_NULL() wrapper macro
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 15, 2017, 22:00 UTC
- Message-ID
- <xmqqa858zzb3.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20170615210700.16310-1-avarab@gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 14 quoted lines
> On Thu, Jun 15 2017, Ævar Arnfjörð Bjarmason jotted: >> I'll change it to FREE_AND_NULL and submit my patch as-is, my reading >> of the rest of this thread is that making it a function instead of a >> macro would be interesting, but has its own caveats that are likely >> better considered as part of its own series, whereas this just changes >> existing code to its macro-expanded functional equivalent. > > Here's v3 with that change. Nothing but the macro name (and comments, > commit messages etc. referring to it) have changed. > > Ævar Arnfjörð Bjarmason (2): > git-compat-util: add a FREE_AND_NULL() wrapper around free(ptr); ptr = > NULL > *.[ch] refactoring: make use of the FREE_AND_NULL() macro
Thanks.
Perhaps somebody wants to do a follow-up patch on top of these two patches to add .cocci rule e.g.
@@ type T; T *ptr; @@ - free(ptr); - ptr = NULL; + FREE_AND_NULL(ptr);
so that we can periodically sweep new candidates, to which this macro can be applied?