Out of range pointers

Richard Harter g-rh at XAIT.XEROX.COM
Thu Sep 22 18:56:51 AEST 1988


In article <8557 at smoke.ARPA> gwyn at brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes:
>In article <33547 at XAIT.XEROX.COM> g-rh at XAIT.Xerox.COM (Richard Harter) writes:
>>However it would be very nice if there were a library routine that would
>>tell you whether a pointer was legal or not.

>I think if your code has to worry about this, it is ALREADY in trouble.
>Pointers should come in two flavors: null (which is easy to test) and
>valid (which you should be able to assume when non-null).

Oh come on now, my code is never in trouble.  What, never?  But it is
just this kind of thinking "you should be able to assume" that leads to
bug-ridden code which lacks robustness.  If one is writing a service
routine one doesn't blissfully assume that the caller hasn't blown it;
one checks the input for validity.  If there is trouble in your routine,
that's your problem.  But if you don't check your input and it violates
your interface assumptions anything can happen.
-- 

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