🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #4548

Re: Alignment of malloc()

#4548
From: Thomas Koenig
Date: Tue, 02 Jan 1996 22:25
24 lines
1781 bytes
In comp.std.c, Michael Spertus<mps@geodesic.com> wrote:

>My question is what the committee means by the words "proper alignment". If
>"proper" COMPLETELY ignores efficiency consideration even if they are
>gross, it means that I would have to align all malloc() returns according to
>the size of the data in all portable code I write.

This is a quality of implementation issue.  In other words, somebody
could write a losing compiler/standard library which generated pessimal
code when malloc() is used with certain data types.  A compiler writer
is also allowed to have the compiler put a loop eating up 100 seconds of
CPU time each time an assignment is made.  Neither would tend to sell
many compilers; neither is likely to be implemented.


>However, I've never seen
>an "ANSI C" textbook that advises aligning malloc() returns by hand.

I know of no compiler which is as brain-damaged as the one you describe;
when I encounter one, I'd tend to howl to the vendor.
-- 
Thomas Koenig, Thomas.Koenig@ciw.uni-karlsruhe.de, ig25@dkauni2.bitnet.
The joy of engineering is to find a straight line on a double
logarithmic diagram.
Technical Details
Message-ID: <4ccbdb$5v6@fg70.rz.uni-karlsruhe.de>
Path: arc1-ca.pugleaf.net!rz.uni-karlsruhe.de!not-for-mail
References: <DKDA7D.Kw7@midway.uchicago.edu> <j66Sx*FRe@yaps.rhein.de> <DKKHCH.L6r@midway.uchicago.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!rz.uni-karlsruhe.de!not-for-mail
From: ig25@fg70.rz.uni-karlsruhe.de (Thomas Koenig)
Newsgroups: comp.std.c
Subject: Re: Alignment of malloc()
Date: 2 Jan 1996 23:25:47 +0100
Organization: Universität Karlsruhe (TH), Germany 
Message-ID: <4ccbdb$5v6@fg70.rz.uni-karlsruhe.de>
References: <DKDA7D.Kw7@midway.uchicago.edu> <j66Sx*FRe@yaps.rhein.de> <DKKHCH.L6r@midway.uchicago.edu>
Reply-To: ig25@mvmap66.ciw.uni-karlsruhe.de
NNTP-Posting-Host: fg70.rz.uni-karlsruhe.de
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
NNTP-Posting-User: ig25