effect of free()

DAVID NEWALL CCDN at levels.sait.edu.au
Fri Sep 15 00:47:43 AEST 1989


In article <10988 at smoke.BRL.MIL>, gwyn at smoke.BRL.MIL (Doug Gwyn) writes:
> In article <1465 at levels.sait.edu.au> CCDN at levels.sait.edu.au (DAVID NEWALL) writes:
> >a machine that *did* trap in such a case, would be decidedly unfriendly.
>
> while letting you continue to play with pointers that point absolutely
> nowhere would be friendly??

I think you're looking at this from the wrong angle.  Don't ask why it
would be friendly to allow invalid pointers (remember that I'm not talking
about dereferencing of invalid pointers), ask instead why it would be
unfriendly to disallow it.  I can think of a few reasons why one might
legitimately want to process such a pointer.  In fact, the definitions for
SIG_DFL and SIG_IGN would seem to be excellent examples of this:
        #define SIG_DFL (int (*)())0
        #define SIG_IGN (int (*)())1

I have a philosophy which I am going to share with you:  Avoid unnecessary
restrictions.  Is it truly necessary that one not be able to *look* at a
pointer without first knowing that it is valid?  I claim that it is not.


David Newall                     Phone:  +61 8 343 3160
Unix Systems Programmer          Fax:    +61 8 349 6939
Academic Computing Service       E-mail: ccdn at levels.sait.oz.au
SA Institute of Technology       Post:   The Levels, South Australia, 5095



More information about the Comp.lang.c mailing list