Path: utzoo!utgpu!attcan!uunet!husc6!XAIT!g-rh From: g-rh@XAIT.XEROX.COM (Richard Harter) Newsgroups: comp.lang.c Subject: Re: Out of range pointers Message-ID: <34041@XAIT.XEROX.COM> Date: 29 Sep 88 15:26:35 GMT References: <867@osupyr.mast.ohio-state.edu> <3200@geac.UUCP> <1430@ficc.uu.net> <1988Sep15.145026.20325@ateng.uucp> <16041@ism780c.isc.com <28227@think.UUCP> <8557@smoke.ARPA> <33666@XAIT.XEROX.COM> <8564@smoke.ARPA> <33789@XAIT.XEROX.COM> <1988Sep27.172738.16453@ut Reply-To: g-rh@XAIT.Xerox.COM (Richard Harter) Organization: Xerox Corporation, Cambridge, Massachusetts Lines: 33 In article <1988Sep27.172738.16453@utzoo.uucp> henry@utzoo.uucp (Henry Spencer) writes: >In article <33789@XAIT.XEROX.COM> g-rh@XAIT.Xerox.COM (Richard Harter) writes: >>... I would say that it pays to perform parameter validation... >True, but in general one must draw the line somewhere. It's almost always >possible to add just one more check. There usually has to be some sort of >balance with efficiency. It is true that one always has to take into account the tradeoff between efficiency and error checking. However that is not normally the tradeoff involved in parameter validation. Unless the body of a function is very short and very fast, parameter validation execution times are a nominal part of the total cost of a function invocation. The real trade offs are between error checking and code size. It costs time and money to write error checking code, and the presence of that code in the source increases both maintenance costs and object code size. Furthermore, not all error checking is of equal value, nor is it always appropriate. If the called routine is essentially a subcomponent of the calling routine, parameter validation is of less value; the two two routines are part of a common package. On the other hand, if the called routine is a service routine, it is much more important to do things like parameter validation. Note: This is not so much a reply to Henry, who knows all these things, but a general comment. -- In the fields of Hell where the grass grows high Are the graves of dreams allowed to die. Richard Harter, SMDS Inc.