Re: [PATCH v2 1/2] git-compat-util: add a FREEZ() wrapper around free(ptr); ptr = NULL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano <gitster@xxxxxxxxx> wrote:
> Eric Wong <e@xxxxxxxxx> 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.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]