Article View: comp.std.c
Article #4514Re: Alignment of malloc()
From: Lawrence Kirby
Date: Sat, 30 Dec 1995 01:25
Date: Sat, 30 Dec 1995 01:25
30 lines
1770 bytes
1770 bytes
In article <DKDA7D.Kw7@midway.uchicago.edu>
mps@geodesic.com "Michael Spertu" writes:
...
>The standard says that the return value of malloc() should be properly aligned
>for all data type. On the one hand, code that uses floats will endure gross
>performance penalties if it doesn't check alignment, and programmers shouldn't
>have to align all their malloc()s. On the other hand, the code still runs,
>albeit inefficiently.
>
>What do you think?
So long as the compiler compiles all strictly conforming programs correctly
(i.e. when run the program's visible side effects are inaccordance with the
standard) the requirements of the standard in this respect are satisfied.
The standard imposes no performance or timing constraints. The actual
requirement for alignment of heap allocations is (7.10.3):
"The pointer returned if the allocation succeeds is suitably aligned so
that it may be assigned to a pointer to any type of object and then used
to access such an object or array of such objects in the space allocated"
The NT implementation conforms to this requirement.
--
-----------------------------------------
Lawrence Kirby | fred@genesis.demon.co.uk
Wilts, England | 70734.126@compuserve.com
-----------------------------------------
Technical Details
Message-ID:
<820286752snz@genesis.demon.co.uk>Path:
arc1-ca.pugleaf.net!mail2news.demon.co.uk!genesis.demon.co.ukReferences:
<DKDA7D.Kw7@midway.uchicago.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!mail2news.demon.co.uk!genesis.demon.co.uk From: Lawrence Kirby <fred@genesis.demon.co.uk> Newsgroups: comp.std.c Subject: Re: Alignment of malloc() Date: Sat, 30 Dec 95 01:25:52 GMT Organization: none Message-ID: <820286752snz@genesis.demon.co.uk> References: <DKDA7D.Kw7@midway.uchicago.edu> Reply-To: fred@genesis.demon.co.uk X-NNTP-Posting-Host: genesis.demon.co.uk X-Newsreader: Demon Internet Simple News v1.27 X-Mail2News-Path: genesis.demon.co.uk