Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!chaph.usc.edu!alcor.usc.edu!jeenglis From: jeenglis@alcor.usc.edu (Joe English Muffin) Newsgroups: comp.lang.c Subject: Re: Just a minor new twist on free() Message-ID: <12332@chaph.usc.edu> Date: 4 Oct 90 05:29:07 GMT References: <1990Oct02.132313.6659@virtech.uucp> Sender: news@chaph.usc.edu Organization: Joe's Homeopathic Hangover Remedies Lines: 37 Nntp-Posting-Host: alcor.usc.edu pds@lemming.webo.dg.com (Paul D. Smith) writes: >Well, IMHO, this is just silliness. What are you saying, that no one >should use ANSI extensions if they have an ANSI compiler just because >they didn't *used* to be legal? That's a valid concern. There are a LOT of systems out there that don't have an ANSI C compiler, and there will be for a long long time to come. ... > #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. Doing the test will most likely INCREASE performance: a test is usually cheaper than a function call, and free() is not a trivial function. Ever profiled a program that made heavy use of malloc() & free()? They eat up a lot of cycles. (Unless the RTL is implemented really well; personally, I've never seen a fast implementation of malloc() & free().) --Joe English jeenglis@alcor.usc.edu