Re: [PATCH v2 1/2] git-compat-util: add a FREEZ() wrapper around free(ptr); ptr = NULL
- From
- Eric Wong <e@80x24.org>
- Date
- Jun 10, 2017, 03:21 UTC
- Message-ID
- <20170610032143.GA7880@starla>
- In-Reply-To
- <xmqq60g462nd.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> wrote:
Show 10 quoted lines
> Eric Wong <e@80x24.org> writes: > > 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?
Perhaps... I think it needs to take "void *" to avoid warnings:
static inline void free_and_null(void *ptrptr)
{
void **tmp = ptrptr;free(*tmp); *tmp = NULL; }
...At least I needed to do that for "mog_free_and_null" in cmogstored:
https://bogomips.org/cmogstored.git/plain/alloc.c?h=v1.6.0
But heck, maybe that's covering up for something else I got wrong in cmogstored *shrug* I don't know all of C.