free() vs xfree() vs FREEIF() vs ISO-C

Andrew Cagney ac131313@cygnus.com
Wed Nov 29 17:43:00 GMT 2000


Hello,

One of the issues that fell out of the alloca() discussion was the
portability of free().  While ISO-C guarentees that free(NULL) doesn't
dump core, many pre-ISO-C libc's don't offer that guarentee.

I can think of several ways of refining the coding standard to avoid
this:

	o	Add/use xfree() which
		would guard against NULL.

	o	adopt FREEIF() for for
		the same reason

	o	leave things as is
		and assume people will
		remember to check the
		arg before calling xfree().

Does anyone have any thoughts?  I tend towards the first one as that is
fairly easy to implement.  If adopted, I'd beg/borrow/con someone into
converting all free() and free((PTR)) calls into xfree() :-)

	Andrew


More information about the Gdb mailing list