Just a minor new twist on free()

Dave Eisen dkeisen at Gang-of-Four.Stanford.EDU
Thu Oct 11 01:54:48 AEST 1990


In article <11 at christmas.UUCP> rtm at island.uu.net (Richard Minner) writes:
>In article <8026 at scolex.sco.COM> seanf (Sean Fagan) writes:
>>And now an ANSI compliant library must have free() check for a NULL
>>parameter, which means that, instead of 10000 tests, you are now doing 20000
>>tests.  Yep.  Just love those performance increases, don't you?
>
>
>The ANSI behavior for free() is a good thing.  I don't want to read
>any more complaints about it ;-)
>

Perfromance isn't really the issue, it's a shame that's what everyone 
keeps bringing up. The performance hit of testing if (ptr == NULL) is 
insignificant whether the test is made before the call to free or within 
free itself.

I'd prefer free not check for NULL pointers because I'd rather have 
my sloppy (and probably incorrect) programming caught by a core dump
than slipping by untouched. I never check for NULL pointers in library
routines that I write unless there is a useful action that should be taken
when that pointer is NULL.



--
Dave Eisen                      	    Home: (415) 323-9757
dkeisen at Gang-of-Four.Stanford.EDU           Office: (415) 967-5644
1447 N. Shoreline Blvd.
Mountain View, CA 94043



More information about the Comp.lang.c mailing list