Path: utzoo!yunexus!geac!syntron!jtsv16!uunet!auspex!guy From: guy@auspex.UUCP (Guy Harris) Newsgroups: comp.lang.c Subject: Re: Efficient coding considered harmful? Message-ID: <342@auspex.UUCP> Date: 28 Oct 88 16:20:27 GMT Article-I.D.: auspex.342 References: <3105@hubcap.UUCP> <34112@XAIT.XEROX.COM> <1700@dataio.Data-IO.COM> <8630@smoke.ARPA> <1704@dataio.Data-IO.COM> <119@twwells.uu Reply-To: guy@auspex.UUCP (Guy Harris) Organization: Auspex Systems, Santa Clara Lines: 12 >: o Use realloc instead of malloc/free pairs. Use calloc instead of >: malloc followed by zeroing each member. > >Realloc has to copy data, so this should be less efficient than just >doing another malloc & free. Err, umm, "realloc" is often used when you have e.g. an array with N filled-in elements, and you want to add some more elements; in this case, if you do another "malloc" and "free", you'll have to copy the entire array *anyway*; some "realloc" implementations may be able to avoid this if they can tell that the extra data can simply be pasted onto the end of the existing array.