aboutsummaryrefslogtreecommitdiffstats
path: root/doc/info
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2015-10-18 03:09:43 +0200
committerMattias Andrée <maandree@operamail.com>2015-10-18 03:09:43 +0200
commitcec0afd4a3ac765532a9730bd3ce2978ceb16107 (patch)
treec7bbdef9ede994968719e1f95fb4f24921a538db /doc/info
parentm info (diff)
downloadslibc-cec0afd4a3ac765532a9730bd3ce2978ceb16107.tar.gz
slibc-cec0afd4a3ac765532a9730bd3ce2978ceb16107.tar.bz2
slibc-cec0afd4a3ac765532a9730bd3ce2978ceb16107.tar.xz
info: aligments
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'doc/info')
-rw-r--r--doc/info/chap/memory-allocation.texinfo19
1 files changed, 19 insertions, 0 deletions
diff --git a/doc/info/chap/memory-allocation.texinfo b/doc/info/chap/memory-allocation.texinfo
index a368aea..141abaa 100644
--- a/doc/info/chap/memory-allocation.texinfo
+++ b/doc/info/chap/memory-allocation.texinfo
@@ -659,6 +659,25 @@ It is unspecified how the function works. The
implemention in @code{slibc} will allocate a bit
of extra memory and shift the returned pointer
so that it is aligned.
+
+A recommended practice, to align pointers is:
+@example
+p = aligned_alloc(sizeof(*p), n)
+@end example
+
+@tpindex max_align_t
+@sc{ISO}@tie{}C11 defines the auxiliary data
+type @code{max_align_t} which has a size
+the guaranteed to be a power-of-two (possibly
+1) multiple of the size of any intrinsic data
+type defined by the C standard. Its size it
+hence suitable for the aligment of any pointer
+to such data type. It can thus be a good idea
+to try replacing @code{malloc} with the macro
+@example
+#define malloc(n) \
+ aligned_alloc(sizeof(max_align_t), n)
+@end example
@end table