Article View: comp.std.c
Article #4513Re: Alignment of malloc()
From: Arno Eigenwillig
Date: Sat, 30 Dec 1995 01:14
Date: Sat, 30 Dec 1995 01:14
23 lines
1505 bytes
1505 bytes
In article <DKDA7D.Kw7@midway.uchicago.edu>, 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. That is a quality-of-implementation issue and hence beyond the scope of The Standard. All The Standard defines in the end is the output a C program creates, not the timing nor (thanks to the as-if rule) the way it creates it. It should be relatively easy to write your own malloc() wrapper, though, that calls malloc() for a slightly [1] larger block and returns a better aligned pointer to within that block. _______ [1] new_blocksize - old_blocksize, that is -- __ __/// Arno Eigenwillig /\ <arno@yaps.rhein.de> \/ PGP key \XX/ V+49-2225-5870 /\ <Arnooo @ #amigager> \/ available
Technical Details
Message-ID:
<j66Sx*FRe@yaps.rhein.de>Path:
arc1-ca.pugleaf.net!phoenix.rhein.de!yaps!arnoReferences:
<DKDA7D.Kw7@midway.uchicago.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!phoenix.rhein.de!yaps!arno From: arno@yaps.rhein.de (Arno Eigenwillig) Newsgroups: comp.std.c Subject: Re: Alignment of malloc() Message-ID: <j66Sx*FRe@yaps.rhein.de> Date: Sat, 30 Dec 1995 02:14:43 +0100 References: <DKDA7D.Kw7@midway.uchicago.edu> Organization: Yet Another Private Site in Meckenheim, Germany X-Copyright: This article may not be distributed on a CD-ROM or in printed form without prior written consent of the author. X-Newsreader: Arn V 1.04