Out of range pointers

Richard Harter g-rh at XAIT.XEROX.COM
Fri Sep 30 01:26:35 AEST 1988


In article <1988Sep27.172738.16453 at utzoo.uucp> henry at utzoo.uucp (Henry Spencer) writes:
>In article <33789 at XAIT.XEROX.COM> g-rh at 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.



More information about the Comp.lang.c mailing list