🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #737

Re: Common malloc/free practice violates ANSI standard ?

#737
From: Richard H. Gumpertz
Date: Sat, 21 Oct 1989 05:17
26 lines
1987 bytes
In article <1989Oct19.101306.16791@twwells.com> bill@twwells.com (T. William Wells) writes:
>The standard requires that casting from (void*) to (OBJ*) and back
>give pointers that compare equal and point to the same object.
>Free will have no problems with it.

WRONG!

This is getting tiring.  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.

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 *.  The standard SHOULD,
however, require this so the programmer does not have to keep an extra,
uncast, pointer around.  Similar for realloc.

Fix the sentences defining free and realloc all is well again.  Why can't people
accept that the standards process overlooked a small nit in the language?  It
was an oversight.  We should be grateful that it was pointed out and fix it in
the next revision.  End of discussion.
-- 
==========================================================================
| Richard H. Gumpertz   rhg@cpsolv.UUCP -or- ...!uunet!amgraf!cpsolv!rhg |
| Computer Problem Solving, 8905 Mohawk Lane, Leawood, Kansas 66206-1749 |
==========================================================================
Technical Details
Message-ID: <423@cpsolv.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!gem.mps.ohio-state.edu!tut.cis.ohio-state.edu!rutgers!texbell!attctc!kcdev!cpsolv!rhg
References: <1989Oct14.043811.669@anucsd.oz> <1989Oct19.101306.16791@twwells.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!gem.mps.ohio-state.edu!tut.cis.ohio-state.edu!rutgers!texbell!attctc!kcdev!cpsolv!rhg
From: rhg@cpsolv.UUCP (Richard H. Gumpertz)
Newsgroups: comp.std.c,comp.lang.c
Subject: Re: Common malloc/free practice violates ANSI standard ?
Message-ID: <423@cpsolv.UUCP>
Date: 21 Oct 89 05:17:59 GMT
References: <1989Oct14.043811.669@anucsd.oz> <1989Oct19.101306.16791@twwells.com>
Reply-To: rhg@cpsolv.uucp (Richard H. Gumpertz)
Organization: Computer Problem Solving, Leawood, Kansas
Lines: 26