effect of free()

Engineering scott at bbxeng.UUCP
Sat Sep 9 09:21:30 AEST 1989


In article <10817 at riks.csl.sony.co.jp> diamond at riks. (Norman Diamond) writes:
>bill at twwells.com (T. William Wells) writes:
>
>
>To cover all cases though:  IT IS MADNESS TO DO ANYTHING WITH A FREED
>POINTER.
>

I figure it is time someone kind of summerized the different points
people have been making in this thread in order to reduce future
use of bandwidth on this topic.

1)  A free()'ed pointer may or may not be pointing to a valid memory
    location.

2)  It is possible that the freed memory block has been returned to the
    system and is no longer in the process's address map.

3)  Therefore, to de-reference such a pointer might cause a trap.

4)  However, on some architectures (i.e. 80286), to merely *load* an
    invalid address *without* de-referencing it could still cause a
    trap.  So, a simple compare operation on an invalid pointer is
    not always safe.

5)  However, a C compiler that attempts to load a segment register (or
    overly sensitive address register) in order to simply *compare*
    addresses is brain damaged.

6)  Therefore, we all agree to avoid those compilers thus driving the
    vendors out of business and we have nothing to worry about.

7)  A list of such vendors would be most welcome so we can begin our
    boycott.  :-)

How about it, folks?

-- 

---------------------------------------
Scott Amspoker
Basis International, Albuquerque, NM
505-345-5232



More information about the Comp.lang.c mailing list