🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #815

Re: Common malloc/free practice violates ANSI standard ?

#815
From: Doug Gwyn
Date: Mon, 23 Oct 1989 14:22
18 lines
1213 bytes
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.
Technical Details
Message-ID: <11386@smoke.BRL.MIL>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!purdue!haven!adm!smoke!gwyn
References: <1989Oct14.043811.669@anucsd.oz> <1989Oct19.101306.16791@twwells.com> <423@cpsolv.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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