Index: libcfa/src/heap.cfa
===================================================================
--- libcfa/src/heap.cfa	(revision 5751a56c72a73cfd724a07d14af375206ec3dcc6)
+++ libcfa/src/heap.cfa	(revision 54eb5ebd44d38f93d7a6ae88f064436d0953610d)
@@ -10,6 +10,6 @@
 // Created On       : Tue Dec 19 21:58:35 2017
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sun Jul 19 17:37:21 2020
-// Update Count     : 806
+// Last Modified On : Mon Jul 20 23:00:32 2020
+// Update Count     : 808
 //
 
@@ -901,4 +901,5 @@
 	  if ( oalign == 0 && size <= odsize && odsize <= size * 2 ) { // allow 50% wasted storage for smaller size
 			header->kind.real.blockSize &= -2;			// no alignment and turn off 0 fill
+			if ( size != odsize ) header->kind.real.size = size; // reset allocation size
 			return oaddr;
 		} // if
@@ -929,7 +930,6 @@
 
 		size_t odsize = dataStorage( bsize, oaddr, header ); // data storage available in bucket
-	  if ( size <= odsize && odsize <= size * 2 ) {	// allow up to 50% wasted storage in smaller size
-			// Do not know size of original allocation => cannot do 0 fill for any additional space because do not know
-			// where to start filling, i.e., do not overwrite existing values in space.
+	  if ( size <= odsize && odsize <= size * 2 ) {		// allow up to 50% wasted storage in smaller size
+			if ( size != odsize ) header->kind.real.size = size; // reset allocation size
 			return oaddr;
 		} // if
@@ -1227,4 +1227,5 @@
 		if ( size <= odsize && odsize <= size * 2 ) {	// allow 50% wasted storage for smaller size
 			header->kind.real.blockSize &= -2;			// turn off 0 fill
+			if ( size != odsize ) header->kind.real.size = size; // reset allocation size
 			return oaddr;
 		} // if
Index: libcfa/src/heap.hfa
===================================================================
--- libcfa/src/heap.hfa	(revision 5751a56c72a73cfd724a07d14af375206ec3dcc6)
+++ libcfa/src/heap.hfa	(revision 54eb5ebd44d38f93d7a6ae88f064436d0953610d)
@@ -10,6 +10,6 @@
 // Created On       : Tue May 26 11:23:55 2020
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Mon Jun  1 21:19:00 2020
-// Update Count     : 10
+// Last Modified On : Mon Jul 20 18:52:31 2020
+// Update Count     : 11
 // 
 
@@ -35,5 +35,5 @@
 	void * resize( void * oaddr, size_t size );
 	void * amemalign( size_t align, size_t dim, size_t elemSize );
-	void * cmemalign( size_t align, size_t noOfElems, size_t elemSize );
+	void * cmemalign( size_t align, size_t dim, size_t elemSize );
 	size_t malloc_alignment( void * addr );
 	bool malloc_zero_fill( void * addr );
Index: libcfa/src/stdlib.hfa
===================================================================
--- libcfa/src/stdlib.hfa	(revision 5751a56c72a73cfd724a07d14af375206ec3dcc6)
+++ libcfa/src/stdlib.hfa	(revision 54eb5ebd44d38f93d7a6ae88f064436d0953610d)
@@ -10,6 +10,6 @@
 // Created On       : Thu Jan 28 17:12:35 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Mon Jul 20 14:29:21 2020
-// Update Count     : 464
+// Last Modified On : Tue Jul 21 07:58:05 2020
+// Update Count     : 475
 //
 
@@ -39,37 +39,41 @@
 //---------------------------------------
 
+// Macro because of returns
+#define $VAR_ALLOC( allocation, alignment ) \
+	if ( _Alignof(T) <= libAlign() ) return (T *)(void *)allocation( (size_t)sizeof(T) ); /* C allocation */ \
+	else return (T *)alignment( _Alignof(T), sizeof(T) )
+
+#define $ARRAY_ALLOC( allocation, alignment, dim ) \
+	if ( _Alignof(T) <= libAlign() ) return (T *)(void *)allocation( dim, (size_t)sizeof(T) ); /* C allocation */ \
+	else return (T *)alignment( _Alignof(T), dim, sizeof(T) )
+
+#define $RE_SPECIALS( ptr, size, allocation, alignment ) \
+	if ( unlikely( size == 0 ) || unlikely( ptr == 0p ) ) { \
+		if ( unlikely( size == 0 ) ) free( ptr ); \
+		$VAR_ALLOC( malloc, memalign ); \
+	} /* if */
+
 static inline forall( dtype T | sized(T) ) {
 	// Cforall safe equivalents, i.e., implicit size specification
 
 	T * malloc( void ) {
-		if ( _Alignof(T) <= libAlign() ) return (T *)(void *)malloc( (size_t)sizeof(T) ); // C malloc
-		else return (T *)memalign( _Alignof(T), sizeof(T) );
+		$VAR_ALLOC( malloc, memalign );
 	} // malloc
 
 	T * aalloc( size_t dim ) {
-		if ( _Alignof(T) <= libAlign() ) return (T *)(void *)aalloc( dim, (size_t)sizeof(T) ); // CFA aalloc
-		else return (T *)amemalign( _Alignof(T), dim, sizeof(T) );
+		$ARRAY_ALLOC( aalloc, amemalign, dim );
 	} // aalloc
 
 	T * calloc( size_t dim ) {
-		if ( _Alignof(T) <= libAlign() )return (T *)(void *)calloc( dim, sizeof(T) ); // C calloc
-		else return (T *)cmemalign( _Alignof(T), dim, sizeof(T) );
+		$ARRAY_ALLOC( calloc, cmemalign, dim );
 	} // calloc
 
 	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 ); // C malloc
-			else return (T *)memalign( _Alignof(T), size );	// C memalign
-		} // if
+		$RE_SPECIALS( ptr, size, malloc, memalign );
 		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 ); // C malloc
-			else return (T *)memalign( _Alignof(T), size );	// C memalign
-		} // if
+		$RE_SPECIALS( ptr, size, malloc, memalign );
 		return (T *)(void *)realloc( (void *)ptr, size ); // C realloc
 	} // realloc
@@ -159,6 +163,6 @@
 	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
+		size_t nsize = dim * sizeof(T);					// new allocation
+		T * nptr = realloc( ptr, nsize );				// CFA realloc
 		if ( nsize > osize ) {							// larger ?
 			memset( (char *)nptr + osize, (int)fill, nsize - osize ); // initialize added storage
@@ -168,7 +172,8 @@
 
 	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
+		size_t odim = malloc_size( ptr ) / sizeof(T);	// current dimension
+		size_t nsize = dim * sizeof(T);					// new allocation
+		size_t ndim = nsize / sizeof(T);				// new dimension
+		T * nptr = realloc( ptr, nsize );				// CFA realloc
 		if ( ndim > odim ) {							// larger ?
 			for ( i; odim ~ ndim ) {
@@ -226,6 +231,6 @@
 	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
+		size_t nsize = dim * sizeof(T);					// new allocation
+		T * nptr = realloc( ptr, align, nsize );		// CFA realloc
 		if ( nsize > osize ) {							// larger ?
 			memset( (char *)nptr + osize, (int)fill, nsize - osize ); // initialize added storage
@@ -235,7 +240,8 @@
 
 	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
+		size_t odim = malloc_size( ptr ) / sizeof(T);	// current dimension
+		size_t nsize = dim * sizeof(T);					// new allocation
+		size_t ndim = nsize / sizeof(T);				// new dimension
+		T * nptr = realloc( ptr, align, nsize );		// CFA realloc
 		if ( ndim > odim ) {							// larger ?
 			for ( i; odim ~ ndim ) {
