Path: utzoo!attcan!uunet!world!decwrl!shelby!neon!Gang-of-Four!dkeisen From: dkeisen@Gang-of-Four.Stanford.EDU (Dave Eisen) Newsgroups: comp.lang.c Subject: Re: Just a minor new twist on free() Message-ID: <1990Oct10.155448.1465@Neon.Stanford.EDU> Date: 10 Oct 90 15:54:48 GMT References: <8026@scolex.sco.COM> <11@christmas.UUCP> Sender: news@Neon.Stanford.EDU (USENET News System) Organization: Sequoia Peripherals Lines: 29 In article <11@christmas.UUCP> rtm@island.uu.net (Richard Minner) writes: >In article <8026@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@Gang-of-Four.Stanford.EDU Office: (415) 967-5644 1447 N. Shoreline Blvd. Mountain View, CA 94043