Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!texbell!sequoia!rpp386!jfh From: jfh@rpp386.cactus.org (John F. Haugh II) Newsgroups: comp.std.c Subject: free behavior (was: Re: Out-of-bounds pointers) Summary: what does free() really do? Message-ID: <17119@rpp386.cactus.org> Date: 10 Oct 89 05:58:47 GMT References: <1009@mtxinu.UUCP> <12570028@hpclwjm.HP.COM> <868@crdos1.crd.ge.COM> <217@bbxsda.UUCP> <11234@smoke.BRL.MIL> Reply-To: jfh@rpp386.cactus.org (John F. Haugh II) Organization: Little or None. Lines: 20 In article <11234@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes: >NO NO NO. You have mispresented the argument. So long as malloc() >(assumed to be properly declared!) doesn't return a null pointer, >the above will work in ALL conforming implementations. The trouble >arises only when after the free() the pointer p (NOT what it points >to, that's inarguably invalid) continues to be examined or otherwise >manipulated by the program. I only bring this up because I've been asleep ... Doesn't free() insure the pointer remains valid until the next call to malloc(). This seems to be implied by the statement that realloc() works if the pointer was used as an argument since the last call to malloc(). This would seem to imply that for this to work, the pointer passed to free -must- remain valid. -- John F. Haugh II +-Things you didn't want to know:------ VoiceNet: (512) 832-8832 Data: -8835 | The real meaning of MACH is ... InterNet: jfh@rpp386.cactus.org | ... Messages Are Crufty Hacks. UUCPNet: {texbell|bigtex}!rpp386!jfh +--------------------------------------