From 8aee94558b01383867b3d9f93a19ba47e51c063d Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 18 Oct 2015 04:28:03 +0200 Subject: the pointer returned by malloc is aligned MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- include/malloc.h | 6 +++++- include/stddef.h | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/malloc.h b/include/malloc.h index 28f937c..66adcbd 100644 --- a/include/malloc.h +++ b/include/malloc.h @@ -37,6 +37,8 @@ /** * Create a new memory allocation on the heap. * The allocation will not be initialised. + * The returned pointer has an alignment usable + * for any compiler-independent intrinsic data type. * * @param size The size of the allocation. * @return Pointer to the beginning of the new allocation. @@ -99,7 +101,9 @@ void* zalloc(size_t) /** * Variant of `malloc` that extends, or shrinks, an existing allocation, * if beneficial and possible, or creates a new allocation with the new - * size, copies the data, and frees the old allocation. + * size, copies the data, and frees the old allocation. The returned + * pointer has an alignment usable for any compiler-independent intrinsic + * data type, if a new pointer is returned. * * On error, `ptr` is not freed. * diff --git a/include/stddef.h b/include/stddef.h index e33cfed..50e9ba1 100644 --- a/include/stddef.h +++ b/include/stddef.h @@ -82,7 +82,7 @@ #define __NEED_ptrdiff_t #define __NEED_wchar_t #define __NEED_size_t -#if defined(__C11__) +#if defined(__C11__) || defined(__BUILDING_SLIBC) # define __NEED_max_align_t #endif -- cgit v1.2.3-70-g09d2