Re: [PATCH v2 1/2] git-compat-util: add a FREEZ() wrapper around free(ptr); ptr = NULL
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 10, 2017, 01:40 UTC
- Message-ID
- <xmqq60g462nd.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20170609233701.GA7195@whir>
Eric Wong <e@80x24.org> writes:
Show 18 quoted lines
> Jonathan Nieder <jrnieder@gmail.com> wrote: >> Hi, >> >> Ævar Arnfjörð Bjarmason wrote: >> >> > Add a FREEZ() wrapper marco for the common pattern of freeing a >> > pointer and assigning NULL to it right afterwards. >> >> I'm conflicted. On one hand it makes code more concise and makes it >> easier for people to remember to assign NULL after freeing a variable. >> On the other hand it makes git more of a custom dialect of C, which >> may make the code harder to read and hack on for new contributors. > > I think this problem could be avoided by using a more explicit > name, perhaps: "free_and_null" > > Seeing the initial subject, I thought this series was short for > "freeze" (like "creat").
Both match my thoughts exactly ;-)
Show 5 quoted lines
> ... > I don't see the point of a macro wrapper, forcing the user to > type out the '&' should drive home the point that the pointer > gets set to NULL. I also find capitalization tiring-to-read > because all characters are the same height.
Sounds sensible.
So make Jonathan's freez_impl a public API and rename it to free_and_null(), perhaps?