This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Does malloc tell us anything about alignment modulo k?
- From: Paolo Carlini <pcarlini at suse dot de>
- To: Daniel Berlin <dberlin at dberlin dot org>
- Cc: "gcc at gcc dot gnu dot org list" <gcc at gcc dot gnu dot org>
- Date: Thu, 15 Jul 2004 16:42:10 +0200
- Subject: Re: Does malloc tell us anything about alignment modulo k?
- References: <3F979366-D66C-11D8-A090-000A95DA505C@dberlin.org>
Daniel Berlin wrote:
I'm working on some trivial alignment analysis.
Malloc'd memory is supposed to be "aligned suitably for any data type".
Does this actually tell us anything about whether the result is
aligned modulo k (IE aligned to a k byte boundary)?
Hi.
In the glibc docs you can find these sentences (which I have always
trusted):
Allocating Aligned Memory Blocks
................................
The address of a block returned by `malloc' or `realloc' in the GNU
system is always a multiple of eight (or sixteen on 64-bit systems).
If you need a block whose address is a multiple of a higher power of
two than that, use `memalign', `posix_memalign', or `valloc'.
...
Paolo.