Xref: utzoo comp.std.c:1822 comp.lang.c:22867 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!uakari.primate.wisc.edu!nic.MR.NET!thor.acc.stolaf.edu!mike From: mike@thor.acc.stolaf.edu (Mike Haertel) Newsgroups: comp.std.c,comp.lang.c Subject: Re: Common malloc/free practice violates ANSI standard ? Message-ID: <7366@thor.acc.stolaf.edu> Date: 15 Oct 89 17:42:16 GMT References: <1989Oct14.043811.669@anucsd.oz> Reply-To: mike@thor.stolaf.edu () Followup-To: comp.std.c Organization: St. Olaf College, Northfield, MN Lines: 17 In article <1989Oct14.043811.669@anucsd.oz> bdm@anucsd.oz (Brendan McKay) writes: >* assigning a void* to an OBJ* involves rounding up to an even address The standard doesn't say anything about "rounding" pointers. Assigning a misaligned void* to an OBJ* might well cause a trap when the OBJ* is dereferenced. Or even when the void* is just assigned to it! >* malloc allocates sufficient space so that it will cover an object of > type OBJ even when the void* value returned is rounded up to even. > (Thus, sometimes it actually allocates one more cell than it is asked for.) No! The pointer returned by malloc() always has the most pessimistic necessary alignment. -- Mike Haertel ``There's nothing remarkable about it. All one has to do is hit the right keys at the right time and the instrument plays itself.'' -- J. S. Bach