Path: utzoo!utgpu!watmath!att!tut.cis.ohio-state.edu!brutus.cs.uiuc.edu!apple!landon From: landon@Apple.COM (Landon Dyer) Newsgroups: comp.lang.c Subject: Re: effect of free(...) Message-ID: <33994@apple.Apple.COM> Date: 15 Aug 89 01:54:25 GMT Organization: Apple Computer Inc., Cupertino, CA Lines: 24 ping@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?"