Index: src/libcfa/stdlib
===================================================================
--- src/libcfa/stdlib	(revision 2ab67b9735bea8d47248cfb229dae71aca39af2e)
+++ src/libcfa/stdlib	(revision f3fc631fd4c6f01e9eff41521dac0171ea98fa7e)
@@ -10,6 +10,6 @@
 // Created On       : Thu Jan 28 17:12:35 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Wed May 24 18:06:27 2017
-// Update Count     : 115
+// Last Modified On : Tue May 30 09:07:35 2017
+// Update Count     : 164
 //
 
@@ -28,21 +28,116 @@
 //---------------------------------------
 
-forall( dtype T | sized(T) ) T * malloc( void );
-forall( dtype T | sized(T) ) T * malloc( char fill );
-forall( dtype T | sized(T) ) T * malloc( T * ptr, size_t size );
-forall( dtype T | sized(T) ) T * malloc( T * ptr, size_t size, unsigned char fill );
-extern "C" { void * calloc( size_t nmemb, size_t size ); } // use default C routine for void *
-forall( dtype T | sized(T) ) T * calloc( size_t nmemb );
+extern "C" { void * memset( void * dest, int c, size_t size ); } // use default C routine for void *
+
+// allocation, non-array types
+static inline forall( dtype T | sized(T) ) T * malloc( void ) {
+	//printf( "X1\n" );
+	return (T *)(void *)malloc( (size_t)sizeof(T) );	// C malloc
+} // malloc
+static inline forall( dtype T | sized(T) ) T * malloc( char fill ) {
+	//printf( "X2\n" );
+	T * ptr = (T *)(void *)malloc( (size_t)sizeof(T) );	// C malloc
+    return memset( ptr, (int)fill, sizeof(T) );			// initial with fill value
+} // malloc
+
+// allocation, array types
+extern "C" { void * calloc( size_t dim, size_t size ); } // use default C routine for void *
+static inline forall( dtype T | sized(T) ) T * calloc( size_t dim ) {
+	//printf( "X3\n" );
+	return (T *)(void *)calloc( dim, sizeof(T) );		// C cmalloc
+}
+static inline forall( dtype T | sized(T) ) T * amalloc( size_t dim ) { // alternative name
+	//printf( "X4\n" );
+	return (T *)(void *)malloc( dim * (size_t)sizeof(T) ); // C malloc
+} // amalloc
+static inline forall( dtype T | sized(T) ) T * amalloc( size_t dim, char fill ) { // alternative name
+	//printf( "X5\n" );
+	T * ptr = (T *)(void *)malloc( dim * (size_t)sizeof(T) ); // C malloc
+    return memset( ptr, (int)fill, dim * sizeof(T) );
+} // amalloc
+
+// resize, non-array types
 extern "C" { void * realloc( void * ptr, size_t size ); } // use default C routine for void *
-forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size );
-forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size, unsigned char fill );
-
-forall( dtype T | sized(T) ) T * aligned_alloc( size_t alignment );
-forall( dtype T | sized(T) ) T * memalign( size_t alignment );		// deprecated
-forall( dtype T | sized(T) ) int posix_memalign( T ** ptr, size_t alignment );
-
+static inline forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size ) {
+	//printf( "X5.5\n" );
+	return (T *)(void *)realloc( (void *)ptr, size );
+}
+forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size, char fill );
+static inline forall( dtype T | sized(T) ) T * malloc( T * ptr, size_t size ) {	// alternative name
+	//printf( "X7\n" );
+	return realloc( ptr, size );
+} // malloc
+static inline forall( dtype T | sized(T) ) T * malloc( T * ptr, size_t size, char fill ) { // alternative name
+	//printf( "X8\n" );
+	return realloc( ptr, size, fill );
+} // malloc
+
+// resize, array types
+static inline forall( dtype T | sized(T) ) T * amalloc( T * ptr, size_t dim ) {
+	//printf( "X9\n" );
+	return malloc( ptr, dim * (size_t)sizeof(T) );
+} // amalloc
+static inline forall( dtype T | sized(T) ) T * amalloc( T * ptr, size_t dim, char fill ) {
+	//printf( "X10\n" );
+	return malloc( ptr, dim * (size_t)sizeof(T), fill );
+} // amalloc
+
+// alignment, non-array types
+extern "C" { void * memalign( size_t alignment, size_t size ); } // use default C routine for void *
+static inline forall( dtype T | sized(T) ) T * memalign( size_t alignment ) {
+	//printf( "X11\n" );
+	return (T *)memalign( alignment, sizeof(T) );
+} // memalign
+static inline forall( dtype T | sized(T) ) T * memalign( size_t alignment, char fill ) {
+	//printf( "X12\n" );
+    T * ptr = (T *)memalign( alignment, sizeof(T) );
+    return memset( ptr, (int)fill, sizeof(T) );
+} // memalign
+static inline forall( dtype T | sized(T) ) T * aligned_alloc( size_t alignment ) {
+	//printf( "X13\n" );
+	return (T *)memalign( alignment, sizeof(T) );
+} // aligned_alloc
+extern "C" { int posix_memalign( void ** ptr, size_t alignment, size_t size ); } // use default C routine for void *
+static inline forall( dtype T | sized(T) ) int posix_memalign( T ** ptr, size_t alignment ) {
+	//printf( "X14\n" );
+	return posix_memalign( (void **)ptr, alignment, sizeof(T) );
+} // posix_memalign
+
+// alignment, array types
+static inline forall( dtype T | sized(T) ) T * amemalign( size_t alignment, size_t dim ) {
+	//printf( "X15\n" );
+	return (T *)memalign( alignment, dim * sizeof(T) );
+} // amemalign
+static inline forall( dtype T | sized(T) ) T * amemalign( size_t alignment, size_t dim, char fill ) {
+	//printf( "X16\n" );
+    T * ptr = (T *)memalign( alignment, dim * sizeof(T) );
+    return memset( ptr, (int)fill, dim * sizeof(T) );
+} // amemalign
+
+// data, non-array types
+static inline forall( dtype T | sized(T) ) T * memset( T * dest, char c ) {
+	//printf( "X17\n" );
+	return memset( dest, c, sizeof(T) );
+} // memset
+extern "C" { void * memcpy( void * dest, const void * src, size_t size ); } // use default C routine for void *
+static inline forall( dtype T | sized(T) ) T * memcpy( T * dest, const T * src ) {
+	//printf( "X18\n" );
+	return memcpy( dest, src, sizeof(T) );
+} // memcpy
+
+// data, array types
+static inline forall( dtype T | sized(T) ) T * amemset( T * dest, size_t dim, char c ) {
+	//printf( "X19\n" );
+	return memset( dest, c, dim * sizeof(T) );
+} // amemset
+static inline forall( dtype T | sized(T) ) T * amemcpy( T * dest, const T * src, size_t dim ) {
+	//printf( "X20\n" );
+	return memcpy( dest, src, dim * sizeof(T) );
+} // amemcpy
+
+// allocation/deallocation and constructor/destructor
 forall( dtype T, ttype Params | sized(T) | { void ?{}(T *, Params); } ) T * new( Params p );
-forall( dtype T | { void ^?{}(T *); } ) void delete( T * ptr );
-forall( dtype T, ttype Params | { void ^?{}(T *); void delete(Params); } ) void delete( T * ptr, Params rest );
+forall( dtype T | { void ^?{}( T * ); } ) void delete( T * ptr );
+forall( dtype T, ttype Params | { void ^?{}( T * ); void delete( Params ); } ) void delete( T * ptr, Params rest );
 
 //---------------------------------------
@@ -77,12 +172,12 @@
 
 forall( otype T | { int ?<?( T, T ); } )
-T * bsearch( T key, const T * arr, size_t dimension );
-
-forall( otype T | { int ?<?( T, T ); } )
-unsigned int bsearch( T key, const T * arr, size_t dimension );
-
-
-forall( otype T | { int ?<?( T, T ); } )
-void qsort( const T * arr, size_t dimension );
+T * bsearch( T key, const T * arr, size_t dim );
+
+forall( otype T | { int ?<?( T, T ); } )
+unsigned int bsearch( T key, const T * arr, size_t dim );
+
+
+forall( otype T | { int ?<?( T, T ); } )
+void qsort( const T * arr, size_t dim );
 
 //---------------------------------------
Index: src/libcfa/stdlib.c
===================================================================
--- src/libcfa/stdlib.c	(revision 2ab67b9735bea8d47248cfb229dae71aca39af2e)
+++ src/libcfa/stdlib.c	(revision f3fc631fd4c6f01e9eff41521dac0171ea98fa7e)
@@ -10,6 +10,6 @@
 // Created On       : Thu Jan 28 17:10:29 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Wed May 24 18:13:15 2017
-// Update Count     : 198
+// Last Modified On : Tue May 30 09:07:56 2017
+// Update Count     : 237
 //
 
@@ -21,5 +21,5 @@
 #define _XOPEN_SOURCE 600								// posix_memalign, *rand48
 #include <stdlib.h>										// malloc, free, calloc, realloc, memalign, posix_memalign, bsearch
-#include <string.h>										// memset
+#include <string.h>										// memcpy, memset
 #include <malloc.h>										// malloc_usable_size
 #include <math.h>										// fabsf, fabs, fabsl
@@ -27,71 +27,36 @@
 } // extern "C"
 
-forall( dtype T | sized(T) ) T * malloc( void ) {		// type-safe
-    return (T *)(void *)malloc( (size_t)sizeof(T) );
-} // malloc
-
-forall( dtype T | sized(T) ) T * malloc( char fill ) {	// initial with fill value (like calloc)
-	T * ptr = (T *)(void *)malloc( (size_t)sizeof(T) );
-    return memset( ptr, (int)fill, sizeof(T) );
-} // malloc
-
-forall( dtype T | sized(T) ) T * malloc( T * ptr, size_t size ) { // alternative realloc
-    return (T *)realloc( ptr, size );
-} // malloc
-
-forall( dtype T | sized(T) ) T * malloc( T * ptr, size_t size, unsigned char fill ) { // alternative realloc with fill value
-    return (T *)realloc( ptr, size, fill );
-} // malloc
-
-
-forall( dtype T | sized(T) ) T * calloc( size_t nmemb ) { // type-safe array initialization with fill 0
-    return (T *)calloc( nmemb, sizeof(T) );
-} // calloc
-
-
-forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size ) { // type-safe
-    return (T *)(void *)realloc( (void *)ptr, size );
+// resize, non-array types
+forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size, char fill ) { // alternative realloc with fill value
+	//printf( "X6\n" );
+	size_t olen = malloc_usable_size( ptr );			// current allocation
+    char * nptr = (void *)realloc( (void *)ptr, size );	// C realloc
+	size_t nlen = malloc_usable_size( nptr );			// new allocation
+	if ( nlen > olen ) {								// larger ?
+		memset( nptr + olen, (int)fill, nlen - olen );	// initialize added storage
+	} // 
+    return (T *)nptr;
 } // realloc
 
-forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size, unsigned char fill ) { // alternative realloc with fill value
-    char * nptr = (T *)(void *)realloc( (void *)ptr, size );
-    size_t unused = malloc_usable_size( nptr );
-    memset( nptr + size - unused, (int)fill, unused );	// initialize any new storage
-    return nptr;
-} // realloc
-
-
-forall( dtype T | sized(T) ) T * aligned_alloc( size_t alignment ) { // aligned allocation
-    return (T *)memalign( alignment, sizeof(T) );
-} // aligned_alloc
-
-forall( dtype T | sized(T) ) T * memalign( size_t alignment ) {
-    return (T *)memalign( alignment, sizeof(T) );
-} // memalign
-
-forall( dtype T | sized(T) ) int posix_memalign( T ** ptr, size_t alignment ) {
-    return posix_memalign( (void **)ptr, alignment, sizeof(T) );
-} // posix_memalign
-
-
-forall( dtype T, ttype Params | sized(T) | { void ?{}( T *, Params ); } ) //  new
+// allocation/deallocation and constructor/destructor
+forall( dtype T, ttype Params | sized(T) | { void ?{}( T *, Params ); } )
 T * new( Params p ) {
 	return ((T *)malloc()){ p };
 } // new
 
-forall( dtype T | { void ^?{}(T *); } )					// delete
+forall( dtype T | { void ^?{}( T * ); } )
 void delete( T * ptr ) {
 	if ( ptr ) {
-		^ptr{};
+		^ptr{};											// run destructor
 		free( ptr );
-	}
+	} // if
 } // delete
 
-forall( dtype T, ttype Params | { void ^?{}(T *); void delete(Params); } )
+forall( dtype T, ttype Params | { void ^?{}( T * ); void delete( Params ); } )
 void delete( T * ptr, Params rest ) {
 	if ( ptr ) {
-		^ptr{};
+		^ptr{};											// run destructor
 		free( ptr );
-	}
+	} // if
 	delete( rest );
 } // delete
@@ -242,19 +207,19 @@
 
 forall( otype T | { int ?<?( T, T ); } )
-T * bsearch( T key, const T * arr, size_t dimension ) {
+T * bsearch( T key, const T * arr, size_t dim ) {
 	int comp( const void * t1, const void * t2 ) { return *(T *)t1 < *(T *)t2 ? -1 : *(T *)t2 < *(T *)t1 ? 1 : 0; }
-	return (T *)bsearch( &key, arr, dimension, sizeof(T), comp );
+	return (T *)bsearch( &key, arr, dim, sizeof(T), comp );
 } // bsearch
 
 forall( otype T | { int ?<?( T, T ); } )
-unsigned int bsearch( T key, const T * arr, size_t dimension ) {
-	T *result = bsearch( key, arr, dimension );
-	return result ? result - arr : dimension;			// pointer subtraction includes sizeof(T)
+unsigned int bsearch( T key, const T * arr, size_t dim ) {
+	T *result = bsearch( key, arr, dim );
+	return result ? result - arr : dim;					// pointer subtraction includes sizeof(T)
 } // bsearch
 
 forall( otype T | { int ?<?( T, T ); } )
-void qsort( const T * arr, size_t dimension ) {
+void qsort( const T * arr, size_t dim ) {
 	int comp( const void * t1, const void * t2 ) { return *(T *)t1 < *(T *)t2 ? -1 : *(T *)t2 < *(T *)t1 ? 1 : 0; }
-	qsort( arr, dimension, sizeof(T), comp );
+	qsort( arr, dim, sizeof(T), comp );
 } // qsort
 
