This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]