Index: libcfa/src/heap.cfa
===================================================================
--- libcfa/src/heap.cfa	(revision e95a1170b44d57c450f82df8d406ba7ec2075518)
+++ libcfa/src/heap.cfa	(revision 289a21c8dd17d19251b1aa7b6e997f0ebfef561a)
@@ -10,6 +10,6 @@
 // Created On       : Tue Dec 19 21:58:35 2017
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sat Jun 13 22:42:15 2020
-// Update Count     : 805
+// Last Modified On : Sun Jul 19 17:37:21 2020
+// Update Count     : 806
 //
 
@@ -1098,5 +1098,5 @@
 	// Returns original total allocation size (not bucket size) => array size is dimension * sizeif(T).
 	size_t malloc_size( void * addr ) {
-	  if ( unlikely( addr == 0p ) ) return false;		// null allocation is not zero fill
+	  if ( unlikely( addr == 0p ) ) return 0;			// null allocation has zero size
 		HeapManager.Storage.Header * header = headerAddr( addr );
 		if ( (header->kind.fake.alignment & 1) == 1 ) { // fake header ?
@@ -1108,5 +1108,5 @@
 	// Set allocation size and return previous size.
 	size_t $malloc_size_set( void * addr, size_t size ) {
-	  if ( unlikely( addr == 0p ) ) return false;		// null allocation is not zero fill
+	  if ( unlikely( addr == 0p ) ) return 0;			// null allocation has 0 size
 		HeapManager.Storage.Header * header = headerAddr( addr );
 		if ( (header->kind.fake.alignment & 1) == 1 ) { // fake header ?
Index: libcfa/src/stdlib.cfa
===================================================================
--- libcfa/src/stdlib.cfa	(revision e95a1170b44d57c450f82df8d406ba7ec2075518)
+++ libcfa/src/stdlib.cfa	(revision 289a21c8dd17d19251b1aa7b6e997f0ebfef561a)
@@ -9,7 +9,7 @@
 // Author           : Peter A. Buhr
 // Created On       : Thu Jan 28 17:10:29 2016
-// Last Modified By : Andrew Beach
-// Last Modified On : Tue Jun  2 16:46:00 2020
-// Update Count     : 500
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Sun Jul 19 15:05:28 2020
+// Update Count     : 501
 //
 
@@ -25,50 +25,4 @@
 
 //---------------------------------------
-
-forall( dtype T | sized(T) ) {
-	T * alloc_set( T ptr[], size_t dim, char fill ) {	// realloc array with fill
-		size_t olen = malloc_usable_size( ptr );		// current allocation
-		void * nptr = (void *)realloc( (void *)ptr, dim * sizeof(T) ); // C realloc
-		size_t nlen = malloc_usable_size( nptr );		// new allocation
-		if ( nlen > olen ) {							// larger ?
-			memset( (char *)nptr + olen, (int)fill, nlen - olen ); // initialize added storage
-		} // if
-		return (T *)nptr;
-	} // alloc_set
-
-	T * alloc_set( T ptr[], size_t dim, T fill ) {		// realloc array with fill
-		size_t olen = malloc_usable_size( ptr );		// current allocation
-		void * nptr = (void *)realloc( (void *)ptr, dim * sizeof(T) ); // C realloc
-		size_t nlen = malloc_usable_size( nptr );		// new allocation
-		if ( nlen > olen ) {							// larger ?
-			for ( i; malloc_size( ptr ) / sizeof(T) ~ dim ) {
-				memcpy( &ptr[i], &fill, sizeof(T) );	// initialize with fill value
-			} // for
-		} // if
-		return (T *)nptr;
-	} // alloc_align_set
-
-	T * alloc_align_set( T ptr[], size_t align, char fill ) { // aligned realloc with fill
-		size_t olen = malloc_usable_size( ptr );		// current allocation
-		void * nptr = (void *)realloc( (void *)ptr, align, sizeof(T) ); // CFA realloc
-		// char * nptr = alloc_align( ptr, align );
-		size_t nlen = malloc_usable_size( nptr );		// new allocation
-		if ( nlen > olen ) {							// larger ?
-			memset( (char *)nptr + olen, (int)fill, nlen - olen ); // initialize added storage
-		} // if
-		return (T *)nptr;
-	} // alloc_align_set
-
-	T * alloc_align_set( T ptr[], size_t align, size_t dim, T fill ) { // aligned realloc with fill
-		size_t olen = malloc_usable_size( ptr );		// current allocation
-		void * nptr = (void *)realloc( (void *)ptr, align, sizeof(T) ); // CFA realloc
-		// char * nptr = alloc_align( ptr, align );
-		size_t nlen = malloc_usable_size( nptr );		// new allocation
-		if ( nlen > olen ) {							// larger ?
-			for ( i; dim ) { memcpy( &ptr[i], &fill, sizeof(T) ); } // initialize with fill value
-		} // if
-		return (T *)nptr;
-	} // alloc_align_set
-} // distribution
 
 // allocation/deallocation and constructor/destructor, non-array types
Index: libcfa/src/stdlib.hfa
===================================================================
--- libcfa/src/stdlib.hfa	(revision e95a1170b44d57c450f82df8d406ba7ec2075518)
+++ libcfa/src/stdlib.hfa	(revision 289a21c8dd17d19251b1aa7b6e997f0ebfef561a)
@@ -9,7 +9,7 @@
 // Author           : Peter A. Buhr
 // Created On       : Thu Jan 28 17:12:35 2016
-// Last Modified By : Andrew Beach
-// Last Modified On : Tue Jun  2 16:47:00 2020
-// Update Count     : 451
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Sun Jul 19 18:29:34 2020
+// Update Count     : 463
 //
 
@@ -57,9 +57,19 @@
 	} // calloc
 
-	T * resize( T * ptr, size_t size ) {				// CFA realloc, eliminate return-type cast
-		return (T *)(void *)resize( (void *)ptr, size ); // C realloc
+	T * resize( T * ptr, size_t size ) {				// CFA resize, eliminate return-type cast
+		if ( unlikely( size == 0 ) || unlikely( ptr == 0p ) ) { // special cases
+			if ( unlikely( size == 0 ) ) free( ptr );
+			if ( _Alignof(T) <= libAlign() ) return (T *)(void *)malloc( (size_t)sizeof(T) ); // C malloc
+			else return (T *)memalign( _Alignof(T), sizeof(T) );
+		} // if
+		return (T *)(void *)resize( (void *)ptr, size ); // CFA resize
 	} // resize
 
 	T * realloc( T * ptr, size_t size ) {				// CFA realloc, eliminate return-type cast
+		if ( unlikely( size == 0 ) || unlikely( ptr == 0p ) ) { // special cases
+			if ( unlikely( size == 0 ) ) free( ptr );
+			if ( _Alignof(T) <= libAlign() ) return (T *)(void *)malloc( (size_t)sizeof(T) ); // C malloc
+			else return (T *)memalign( _Alignof(T), sizeof(T) );
+		} // if
 		return (T *)(void *)realloc( (void *)ptr, size ); // C realloc
 	} // realloc
@@ -118,8 +128,8 @@
 
 	T * alloc( T ptr[], size_t dim, bool copy = true ) {
-		if ( copy ) {									// realloc
-			return (T *)(void *)realloc( (void *)ptr, dim * sizeof(T) ); // C realloc
+		if ( copy ) {
+			return realloc( ptr, dim * sizeof(T) );		// CFA realloc
 		} else {
-			return resize( ptr, dim * sizeof(T) );		// resize
+			return resize( ptr, dim * sizeof(T) );		// CFA resize
 		} // if
 	} // alloc
@@ -146,9 +156,26 @@
 		return (T *)memcpy( (T *)alloc( dim ), fill, dim * sizeof(T) ); // initialize with fill value
 	} // alloc
-} // distribution
-
-forall( dtype T | sized(T) ) {
-	T * alloc_set( T ptr[], size_t dim, char fill );	// realloc array with fill
-	T * alloc_set( T ptr[], size_t dim, T fill );		// realloc array with fill
+
+	T * alloc_set( T ptr[], size_t dim, char fill ) {	// realloc array with fill
+		size_t osize = malloc_size( ptr );				// current allocation
+		T * nptr = realloc( ptr, dim * sizeof(T) );		// CFA realloc
+		size_t nsize = malloc_size( nptr );				// new allocation
+		if ( nsize > osize ) {							// larger ?
+			memset( (char *)nptr + osize, (int)fill, nsize - osize ); // initialize added storage
+		} // if
+		return (T *)nptr;
+	} // alloc_set
+
+	T * alloc_set( T ptr[], size_t dim, T & fill ) {	// realloc array with fill
+		size_t odim = malloc_size( ptr ) / sizeof(T);	// current allocation
+		T * nptr = realloc( ptr, dim * sizeof(T) );		// CFA realloc
+		size_t ndim = malloc_size( nptr ) / sizeof(T);	// new allocation
+		if ( ndim > odim ) {							// larger ?
+			for ( i; odim ~ ndim ) {
+				memcpy( &nptr[i], &fill, sizeof(T) );	// initialize with fill value
+			} // for
+		} // if
+		return (T *)nptr;
+	} // alloc_align_set
 } // distribution
 
@@ -196,11 +223,26 @@
 		return (T *)memcpy( (T *)alloc_align( align, dim ), fill, dim * sizeof(T) );
 	} // alloc_align
-} // distribution
-
-forall( dtype T | sized(T) ) {
-	T * alloc_align_set( T ptr[], size_t align, char fill ); // aligned realloc with fill
-	T * alloc_align_set( T ptr[], size_t align, T fill ); // aligned realloc with fill
-	T * alloc_align_set( T ptr[], size_t align, size_t dim, char fill ); // aligned realloc array with fill
-	T * alloc_align_set( T ptr[], size_t align, size_t dim, T fill ); // aligned realloc array with fill
+
+	T * alloc_align_set( T ptr[], size_t align, size_t dim, char fill ) {
+		size_t osize = malloc_size( ptr );				// current allocation
+		T * nptr = realloc( ptr, align, dim * sizeof(T) ); // CFA realloc
+		size_t nsize = malloc_size( nptr );				// new allocation
+		if ( nsize > osize ) {							// larger ?
+			memset( (char *)nptr + osize, (int)fill, nsize - osize ); // initialize added storage
+		} // if
+		return (T *)nptr;
+	} // alloc_align_set
+
+	T * alloc_align_set( T ptr[], size_t align, size_t dim, T & fill ) {
+		size_t odim = malloc_size( ptr ) / sizeof(T);	// current allocation
+		T * nptr = realloc( ptr, align, dim * sizeof(T) ); // CFA realloc
+		size_t ndim = malloc_size( nptr );				// new allocation
+		if ( ndim > odim ) {							// larger ?
+			for ( i; odim ~ ndim ) {
+				memcpy( &nptr[i], &fill, sizeof(T) );	// initialize with fill value
+			} // for
+		} // if
+		return (T *)nptr;
+	} // alloc_align_set
 } // distribution
 
Index: tests/.expect/alloc.txt
===================================================================
--- tests/.expect/alloc.txt	(revision e95a1170b44d57c450f82df8d406ba7ec2075518)
+++ tests/.expect/alloc.txt	(revision 289a21c8dd17d19251b1aa7b6e997f0ebfef561a)
@@ -34,5 +34,5 @@
 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 
 CFA realloc array alloc, fill
-0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 
+0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 
 
 C   memalign 42 42.5
