effect of free(...)

Landon Dyer landon at Apple.COM
Tue Aug 15 11:54:25 AEST 1989


ping at cubmol.BIO.COLUMBIA.EDU (Shiping Zhang) writes:
> Now some new questions arises. Many people said that after free()
> is called, the point used as the argument to free() is still valid
> and can be used IF NO (mc)alloc()'s are called after the call to free().

Definitely not.  Code that does this is NOT portable.

ANSI 4.10.3 sez:

    "The pointer returned if the allocation succeeds ... may be
    ... used to access ... objects in the space allocated until
    the space is explicitly freed or reallocated."


"Foo!" you cry, "It works FINE on my FrobCo Unix(tm) machine!"

Super.  It won't work anywhere else, and it might stop working on YOUR
machine tomorrow.  DO IT RIGHT.

-----------------------------------------
Landon Dyer, Apple Computer, Inc.          "Mmmph!  Urghurmph!  Grugmph!"
Development Systems Group (MPW)            
                                           "What's he trying to say?"



More information about the Comp.lang.c mailing list