Path: utzoo!attcan!uunet!sco!seanf From: seanf@sco.COM (Sean Fagan) Newsgroups: comp.lang.c Subject: Re: Just a minor new twist on free() Message-ID: <8026@scolex.sco.COM> Date: 5 Oct 90 07:26:54 GMT References: <7365@darkstar.ucsc.edu> <1990Oct02.132313.6659@virtech.uucp> Sender: news@sco.COM Reply-To: seanf (Sean Fagan) Organization: The Santa Cruz Operation, Inc. Lines: 27 In article pds@lemming.webo.dg.com (Paul D. Smith) writes: >While your simple case might indeed not be much of a performance hit, >what about something like: > > #define ARRAY_LEN 10000 > char *array[ARRAY_LEN], *ap; > int i; > for (ap = array, i = 0; i < ARRAY_LEN; ++i, ++ap) > { if (ap != NULL) free(ap); } > >Now, *this* is a significant performance hit, if you consider an extra >10000 comparisons. 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? Incidently, in reformating the included text to make news happy, I very nicely got rid of the syntax error (a missing semicolon). Tsk tsk tsk 8-). -- -----------------+ Sean Eric Fagan | "Never knock on Death's door: ring the bell and seanf@sco.COM | run away! Death really hates that!" uunet!sco!seanf | -- Dr. Mike Stratford (Matt Frewer, "Doctor, Doctor") (408) 458-1422 | Any opinions expressed are my own, not my employers'.