Xref: utzoo comp.std.c:1923 comp.lang.c:23150 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!purdue!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.std.c,comp.lang.c Subject: Re: Common malloc/free practice violates ANSI standard ? Message-ID: <11386@smoke.BRL.MIL> Date: 23 Oct 89 14:22:04 GMT References: <1989Oct14.043811.669@anucsd.oz> <1989Oct19.101306.16791@twwells.com> <423@cpsolv.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 18 In article <423@cpsolv.UUCP> rhg@cpsolv.uucp (Richard H. Gumpertz) writes: -This is getting tiring. I agree with THAT. -The standard requires that casting OBJ * to void * and then back to -OBJ * preserve the value. It does NOT (and intentionally so) require -the reverse. But it does when the storage pointed to by the void* is already OBJ-aligned, such as for the (non-null) value returned by malloc(). -The description of free requires it to accept a value previously returned -by malloc. It does not require it to accept a value that was returned from -malloc and then cast to OBJ * and then back to void *. Yes it does, but in more general terms, of which that is merely one consequence.