From: Eric Wong Date: Sat, 10 Jun 2017 03:21:43 GMT Subject: Re: [PATCH v2 1/2] git-compat-util: add a FREEZ() wrapper around free(ptr); ptr = NULL Message-ID: <20170610032143.GA7880@starla> In-Reply-To: Junio C Hamano wrote: > Eric Wong 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.