free behavior (was: Re: Out-of-bounds pointers)

John F. Haugh II jfh at rpp386.cactus.org
Tue Oct 10 15:58:47 AEST 1989


In article <11234 at smoke.BRL.MIL> gwyn at 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 at rpp386.cactus.org         |    ... Messages Are Crufty Hacks.
UUCPNet:  {texbell|bigtex}!rpp386!jfh   +--------------------------------------



More information about the Comp.std.c mailing list