From: Christian Couder Date: Fri, 09 Jun 2017 12:04:49 GMT Subject: Re: [PATCH 1/2] git-compat-util: add a freez() wrapper around free(x); x = NULL Message-ID: In-Reply-To: <20170609085346.19974-2-avarab@gmail.com> On Fri, Jun 9, 2017 at 10:53 AM, Ævar Arnfjörð Bjarmason wrote: > --- a/git-compat-util.h > +++ b/git-compat-util.h > @@ -787,6 +787,7 @@ extern char *xstrdup(const char *str); > extern void *xmalloc(size_t size); > extern void *xmallocz(size_t size); > extern void *xmallocz_gently(size_t size); > +#define freez(p) do { if (p) { free(p); (p) = NULL; } } while (0) I think we already rely on free(NULL) working, see http://public-inbox.org/git/alpine.DEB.2.20.1608301948310.129229@virtualbox/ for example, so this could just be: #define freez(p) do { free(p); (p) = NULL; } while (0) and yeah FREEZ() would be even better than freez().