Index: libcfa/src/heap.cfa
===================================================================
--- libcfa/src/heap.cfa	(revision fd642d2c3aee132ffbce05c2d7092e4dac7fa8d0)
+++ libcfa/src/heap.cfa	(revision 8fc15cf9fe36dc9ac4c58d781d8498b22775ece3)
@@ -10,6 +10,6 @@
 // Created On       : Tue Dec 19 21:58:35 2017
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Jul 19 16:07:46 2019
-// Update Count     : 548
+// Last Modified On : Tue Jul 23 14:13:13 2019
+// Update Count     : 549
 //
 
@@ -869,5 +869,5 @@
 		void * area;
 		if ( unlikely( alignment != 0 ) ) {				// previous request memalign?
-			area = memalign( alignment, size );			// create new area
+			area = memalign( alignment, size );			// create new aligned area
 		} else {
 			area = mallocNoStats( size );				// create new area
Index: libcfa/src/stdlib.hfa
===================================================================
--- libcfa/src/stdlib.hfa	(revision fd642d2c3aee132ffbce05c2d7092e4dac7fa8d0)
+++ libcfa/src/stdlib.hfa	(revision 8fc15cf9fe36dc9ac4c58d781d8498b22775ece3)
@@ -10,6 +10,6 @@
 // Created On       : Thu Jan 28 17:12:35 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Wed Apr 24 17:35:43 2019
-// Update Count     : 352
+// Last Modified On : Tue Jul 23 14:14:59 2019
+// Update Count     : 373
 //
 
@@ -17,6 +17,8 @@
 
 #include "bits/defs.hfa"
+#include "bits/align.hfa"
 
 #include <stdlib.h>										// *alloc, strto*, ato*
+
 extern "C" {
 	void * memalign( size_t align, size_t size );		// malloc.h
@@ -39,12 +41,15 @@
 
 	T * malloc( void ) {
-		return (T *)(void *)malloc( (size_t)sizeof(T) ); // C malloc
+		if ( _Alignof(T) <= libAlign() ) return (T *)(void *)malloc( (size_t)sizeof(T) ); // C malloc
+		else return (T *)memalign( _Alignof(T), sizeof(T) );
 	} // malloc
 
 	T * calloc( size_t dim ) {
-		return (T *)(void *)calloc( dim, sizeof(T) );	// C calloc
+		if ( _Alignof(T) <= libAlign() )return (T *)(void *)calloc( dim, sizeof(T) ); // C calloc
+		else return (T *)cmemalign( _Alignof(T), dim, sizeof(T) );
 	} // calloc
 
 	T * realloc( T * ptr, size_t size ) {
+		if ( unlikely( ptr == 0 ) ) return malloc();
 		return (T *)(void *)realloc( (void *)ptr, size );
 	} // realloc
@@ -66,28 +71,27 @@
 
 	T * alloc( void ) {
-		return (T *)(void *)malloc( (size_t)sizeof(T) ); // C malloc
+		return malloc();
 	} // alloc
 
 	T * alloc( char fill ) {
-		T * ptr = (T *)(void *)malloc( (size_t)sizeof(T) );	// C malloc
+		T * ptr;
+		if ( _Alignof(T) <= libAlign() ) ptr = (T *)(void *)malloc( (size_t)sizeof(T) ); // C malloc
+		else ptr = (T *)memalign( _Alignof(T), sizeof(T) );
 		return (T *)memset( ptr, (int)fill, sizeof(T) ); // initialize with fill value
 	} // alloc
 
 	T * alloc( size_t dim ) {
-		return (T *)(void *)malloc( dim * (size_t)sizeof(T) ); // C malloc
+		if ( _Alignof(T) <= libAlign() ) return (T *)(void *)malloc( dim * (size_t)sizeof(T) ); // C malloc
+		else return (T *)memalign( _Alignof(T), dim * sizeof(T) );
 	} // alloc
 
 	T * alloc( size_t dim, char fill ) {
-		T * ptr = (T *)(void *)malloc( dim * (size_t)sizeof(T) ); // C calloc
-		return (T *)memset( ptr, (int)fill, dim * sizeof(T) ); // initialize with fill value
+		return (T *)memset( (T *)alloc( dim ), (int)fill, dim * sizeof(T) ); // initialize with fill value
 	} // alloc
 
 	T * alloc( T ptr[], size_t dim ) {
-		return (T *)(void *)realloc( (void *)ptr, dim * (size_t)sizeof(T) ); // C realloc
-	} // alloc
-} // distribution
-
-
-forall( dtype T | sized(T) ) T * alloc( T ptr[], size_t dim, char fill );
+		return realloc( ptr, dim * sizeof(T) );
+	} // alloc
+} // distribution
 
 
@@ -107,14 +111,13 @@
 
 	T * align_alloc( size_t align, size_t dim, char fill ) {
-		T * ptr;
 		if ( fill == '\0' ) {
-			ptr = (T *)cmemalign( align, dim, sizeof(T) );
+			return (T *)cmemalign( align, dim, sizeof(T) );
 		} else {
-			ptr = (T *)memalign( align, dim * sizeof(T) );
-			return (T *)memset( ptr, (int)fill, dim * sizeof(T) );
+			return (T *)memset( (T *)memalign( align, dim * sizeof(T) ), (int)fill, dim * sizeof(T) );
 		} // if
-		return ptr;
-	} // align_alloc
-} // distribution
+	} // align_alloc
+} // distribution
+
+forall( dtype T | sized(T) ) T * alloc( T ptr[], size_t dim, char fill );
 
 
