Index: tests/alloc.cfa
===================================================================
--- tests/alloc.cfa	(revision 8e2cb4aa6658f98542c6adf760d5dba01324c12c)
+++ tests/alloc.cfa	(revision 191a19015ebe9917f03b8a35a5f9e245085378e7)
@@ -47,9 +47,9 @@
 	free( ip );
 
-	ip = alloc_set( fill );								// CFA alloc, fill
+	ip = alloc( fill`fill );								// CFA alloc, fill
 	printf( "CFA alloc, fill %08x\n", *ip );
 	free( ip );
 
-	ip = alloc_set( 3 );								// CFA alloc, fill
+	ip = alloc( 3`fill );								// CFA alloc, fill
 	printf( "CFA alloc, fill %d\n", *ip );
 	free( ip );
@@ -78,5 +78,5 @@
 	free( ip );
 
-	ip = alloc_set( 2 * dim, fill );					// CFA array alloc, fill
+	ip = alloc( 2 * dim, fill`fill );					// CFA array alloc, fill
 	printf( "CFA array alloc, fill %#hhx\n", fill );
 	for ( i; 2 * dim ) { printf( "%#x ", ip[i] ); }
@@ -84,5 +84,5 @@
 	free( ip );
 
-	ip = alloc_set( 2 * dim, 0xdeadbeef );				// CFA array alloc, fill
+	ip = alloc( 2 * dim, ((int)0xdeadbeef)`fill );				// CFA array alloc, fill
 	printf( "CFA array alloc, fill %#hhx\n", 0xdeadbeef );
 	for ( i; 2 * dim ) { printf( "%#x ", ip[i] ); }
@@ -90,5 +90,5 @@
 	// do not free
 
-	ip1 = alloc_set( 2 * dim, ip, 2 * dim );				// CFA array alloc, fill
+	ip1 = alloc( 2 * dim, [ip, 2 * dim]`fill );				// CFA array alloc, fill
 	printf( "CFA array alloc, fill from array\n" );
 	for ( i; 2 * dim ) { printf( "%#x %#x, ", ip[i], ip1[i] ); }
@@ -117,5 +117,5 @@
 	printf( "\n" );
 
-	ip = alloc( ip, dim );								// CFA realloc array alloc
+	ip = alloc( dim, ip`realloc );								// CFA realloc array alloc
 	for ( i; dim ) { ip[i] = 0xdeadbeef; }
 	printf( "CFA realloc array alloc\n" );
@@ -124,5 +124,5 @@
 	// do not free
 
-	ip = alloc( ip, 2 * dim );							// CFA realloc array alloc
+	ip = alloc( 2 * dim, ip`realloc );							// CFA realloc array alloc
 	for ( i; dim ~ 2 * dim ) { ip[i] = 0x1010101; }		// fill upper part
 	printf( "CFA realloc array alloc\n" );
@@ -131,5 +131,5 @@
 	// do not free
 
-	ip = alloc( ip, dim );								// CFA realloc array alloc
+	ip = alloc( dim, ip`realloc );								// CFA realloc array alloc
 	printf( "CFA realloc array alloc\n" );
 	for ( i; dim ) { printf( "%#x ", ip[i] ); }
@@ -137,5 +137,5 @@
 	// do not free
 
-	ip = alloc_set( ip, 3 * dim, fill );				// CFA realloc array alloc, fill
+	ip = alloc( 3 * dim, ip`realloc, fill`fill );				// CFA realloc array alloc, fill
 	printf( "CFA realloc array alloc, fill\n" );
 	for ( i; 3 * dim ) { printf( "%#x ", ip[i] ); }
@@ -143,5 +143,5 @@
 	// do not free
 
-	ip = alloc_set( ip, dim, fill );					// CFA realloc array alloc, fill
+	ip = alloc( dim, ip`realloc, fill`fill );					// CFA realloc array alloc, fill
 	printf( "CFA realloc array alloc, fill\n" );
 	for ( i; dim ) { printf( "%#x ", ip[i] ); }
@@ -149,5 +149,5 @@
 	// do not free
 
-	ip = alloc_set( ip, 3 * dim, fill );				// CFA realloc array alloc, fill
+	ip = alloc( 3 * dim, ip`realloc, fill`fill );				// CFA realloc array alloc, fill
 	printf( "CFA realloc array alloc, fill\n" );
 	for ( i; 3 * dim ) { printf( "%#x ", ip[i] ); }
@@ -155,5 +155,5 @@
 	// do not free
 #if 0 // FIX ME
-	ip = alloc_set( ip, 5 * dim, 5 );					// CFA realloc array alloc, 5
+	ip = alloc( 5 * dim, ip`realloc, 5`fill );					// CFA realloc array alloc, 5
 	printf( "CFA realloc array alloc, 5\n" );
 	for ( i; 5 * dim ) { printf( "%#x ", ip[i] ); }
@@ -161,5 +161,5 @@
 	// do not free
 
-	ip = alloc_set( ip, dim, 5 );						// CFA realloc array alloc, 5
+	ip = alloc( dim, ip`realloc, 5`fill );						// CFA realloc array alloc, 5
 	printf( "CFA realloc array alloc, 5\n" );
 	for ( i; dim ) { printf( "%#x ", ip[i] ); }
@@ -167,5 +167,5 @@
 	// do not free
 
-	ip = alloc_set( ip, 5 * dim, 5 );					// CFA realloc array alloc, 5
+	ip = alloc( 5 * dim, ip`realloc, 5`fill );					// CFA realloc array alloc, 5
 	printf( "CFA realloc array alloc, 5\n" );
 	for ( i; 5 * dim ) { printf( "%#x ", ip[i] ); }
@@ -182,9 +182,9 @@
     ip = alloc();
 	*ip = 5;
-    double * dp = alloc( ip );
+    double * dp = alloc( ip`resize );
 	*dp = 5.5;
-    S * sp = alloc( dp );
+    S * sp = alloc( dp`resize );
 	*sp = (S){ {0, 1, 2, 3, 4} };
-    ip = alloc( sp );
+    ip = alloc( sp`resize );
 	*ip = 3;
     free( ip );
@@ -195,13 +195,13 @@
     ip = alloc( 5 );
 	for ( i; 5 ) { ip[i] = 5; }
-    dp = alloc( ip, 5 );
+    dp = alloc( 5, ip`resize );
 	for ( i; 5 ) { dp[i] = 5.5; }
-    sp = alloc( dp, 5 );
+    sp = alloc( 5, dp`resize );
 	for ( i; 5 ) { sp[i] = (S){ {0, 1, 2, 3, 4} }; }
-    ip = alloc( sp, 3 );
+    ip = alloc( 3, sp`resize );
 	for ( i; 3 ) { ip[i] = 3; }
-    ip = alloc( ip, 7 );
+    ip = alloc( 7, ip`realloc );
 	for ( i; 7 ) { ip[i] = 7; }
-    ip = alloc( ip, 7, false );
+    ip = alloc( 7, ip`resize );
 	for ( i; 7 ) { ip[i] = 7; }
     free( ip );
@@ -237,25 +237,25 @@
 	free( stp );
 
-	stp = &(*alloc_align( Alignment)){ 42, 42.5 };		// CFA alloc_align
+	stp = &(*alloc( Alignment`align)){ 42, 42.5 };		// CFA alloc_align
 	assert( (uintptr_t)stp % Alignment == 0 );
 	printf( "CFA alloc_align %d %g\n", stp->x, stp->y );
 	free( stp );
 
-	stp = &(*alloc_align( Alignment )){ 42, 42.5 };		// CFA alloc_align
+	stp = &(*alloc( Alignment`align )){ 42, 42.5 };		// CFA alloc_align
 	assert( (uintptr_t)stp % Alignment == 0 );
 	printf( "CFA alloc_align %d %g\n", stp->x, stp->y );
 	free( stp );
 
-	stp = alloc_align_set( Alignment, fill );			// CFA memalign, fill
+	stp = alloc( Alignment`align, fill`fill );			// CFA memalign, fill
 	assert( (uintptr_t)stp % Alignment == 0 );
 	printf( "CFA alloc_align fill %#x %a\n", stp->x, stp->y );
 	free( stp );
 
-	stp = alloc_align_set( Alignment, (Struct){ 42, 42.5 } ); // CFA memalign, fill
+	stp = alloc( Alignment`align, (Struct){ 42, 42.5 }`fill ); // CFA memalign, fill
 	assert( (uintptr_t)stp % Alignment == 0 );
 	printf( "CFA alloc_align fill %d %g\n", stp->x, stp->y );
 	// do not free
 
-	stp = &(*alloc_align( stp, 4096 )){ 42, 42.5 };		// CFA realign
+	stp = &(*alloc( stp`realloc, 4096`align )){ 42, 42.5 };		// CFA realign
 	assert( (uintptr_t)stp % 4096 == 0 );
 	printf( "CFA alloc_align %d %g\n", stp->x, stp->y );
@@ -266,5 +266,5 @@
 	printf( "\n" );
 
-	stp = alloc_align( Alignment, dim );                // CFA array memalign
+	stp = alloc( dim, Alignment`align );                // CFA array memalign
 	assert( (uintptr_t)stp % Alignment == 0 );
 	for ( i; dim ) { stp[i] = (Struct){ 42, 42.5 }; }
@@ -274,5 +274,5 @@
 	free( stp );
 
-	stp = alloc_align_set( Alignment, dim, fill );		// CFA array memalign, fill
+	stp = alloc( dim, Alignment`align, fill`fill );		// CFA array memalign, fill
 	assert( (uintptr_t)stp % Alignment == 0 );
 	printf( "CFA array alloc_align, fill\n" );
@@ -281,5 +281,5 @@
 	free( stp );
 
-	stp = alloc_align_set( Alignment, dim, (Struct){ 42, 42.5 } ); // CFA array memalign, fill
+	stp = alloc( dim, Alignment`align, ((Struct){ 42, 42.5 })`fill ); // CFA array memalign, fill
 	assert( (uintptr_t)stp % Alignment == 0 );
 	printf( "CFA array alloc_align, fill\n" );
@@ -288,5 +288,5 @@
 	// do not free
 
-	stp1 = alloc_align_set( Alignment, dim, stp, dim );	// CFA array memalign, fill
+	stp1 = alloc( dim, Alignment`align, [stp, dim]`fill );	// CFA array memalign, fill
 	assert( (uintptr_t)stp % Alignment == 0 );
 	printf( "CFA array alloc_align, fill array\n" );
@@ -295,5 +295,5 @@
 	free( stp1 );
 
-	stp = alloc_align( stp, 4096, dim );				// CFA aligned realloc array
+	stp = alloc( dim, stp`realloc, 4096`align );				// CFA aligned realloc array
 	assert( (uintptr_t)stp % 4096 == 0 );
 	for ( i; dim ) { stp[i] = (Struct){ 42, 42.5 }; }
@@ -325,5 +325,4 @@
 	for ( i; dim ) { printf( "%#x %a, ", sta1[i].x, sta1[i].y ); }
 	printf( "\n" );
-
 
 	// new, non-array types
Index: tests/alloc2.cfa
===================================================================
--- tests/alloc2.cfa	(revision 191a19015ebe9917f03b8a35a5f9e245085378e7)
+++ tests/alloc2.cfa	(revision 191a19015ebe9917f03b8a35a5f9e245085378e7)
@@ -0,0 +1,891 @@
+/*
+	some tests are commented-out because of resize/realloc bug from 0p. They should be uncommented after that bug is resolved.
+*/
+
+#include <malloc.h>										// malloc_usable_size
+#include <stdint.h>										// uintptr_t
+#include <stdlib.hfa>									// access C malloc, realloc
+#include <string.h>										// memcmp
+
+int last_failed;
+int tests_total;
+int tests_failed;
+size_t tAlign = 32;
+struct S1 { int data; } __attribute__((aligned(32)));
+typedef struct S1 T1;
+
+void test_base( void * ip, size_t size, size_t align) {
+	tests_total += 1;
+	bool passed = (malloc_size(ip) == size) && (malloc_usable_size(ip) >= size) && (malloc_alignment(ip) == align) && ((uintptr_t)ip % align  == 0);
+	if (!passed) {
+		printf("failed test %3d: %4lu %4lu but got %4lu ( %3lu ) %4lu\n", tests_total, size, align, malloc_size(ip), malloc_usable_size(ip), malloc_alignment(ip));
+//		if (last_failed != tests_total) {
+			tests_failed += 1;
+//			last_failed = tests_total;
+//		}
+	}
+}
+
+void test_fill( void * ip_, size_t start, size_t end, char fill) {
+	tests_total += 1;
+	bool passed = true;
+	char * ip = (char *) ip_;
+	for (i; start ~ end) passed = passed && (ip[i] == fill);
+	if (!passed) {
+		printf("failed test %3d: fill C\n", tests_total);
+//		if (last_failed != tests_total) {
+			tests_failed += 1;
+//			last_failed = tests_total;
+//		}
+	}
+}
+
+void test_fill( void * ip_, size_t start, size_t end, int fill) {
+	tests_total += 1;
+	bool passed = true;
+	int * ip = (int *) ip_;
+	for (i; start ~ end) passed = passed && (ip[i] == fill);
+	if (!passed) {
+		printf("failed test %3d: fill int\n", tests_total);
+//		if (last_failed != tests_total) {
+			tests_failed += 1;
+//			last_failed = tests_total;
+//		}
+	}
+}
+
+void test_fill( void * ip_, size_t start, size_t end, int * fill) {
+	tests_total += 1;
+	bool passed = (memcmp((void*)((uintptr_t)ip_ + start), (void*)fill, end) == 0);
+	if (!passed) {
+		printf("failed test %3d: fill int A\n", tests_total);
+//		if (last_failed != tests_total) {
+			tests_failed += 1;
+//			last_failed = tests_total;
+//		}
+	}
+}
+
+void test_fill( void * ip_, size_t start, size_t end, T1 fill) {
+	tests_total += 1;
+	bool passed = true;
+	T1 * ip = (T1 *) ip_;
+	for (i; start ~ end) passed = passed && (ip[i].data == fill.data);
+	if (!passed) {
+		printf("failed test %3d: fill T1\n", tests_total);
+//		if (last_failed != tests_total) {
+			tests_failed += 1;
+//			last_failed = tests_total;
+//		}
+	}
+}
+
+void test_fill( void * ip_, size_t start, size_t end, T1 * fill) {
+	tests_total += 1;
+	bool passed = (memcmp((void*)((uintptr_t)ip_ + start), (void*)fill, end) == 0);
+	if (!passed) {
+		printf("failed test %3d: fill T1 A\n", tests_total);
+//		if (last_failed != tests_total) {
+			tests_failed += 1;
+//			last_failed = tests_total;
+//		}
+	}
+}
+
+void test_use( int * ip, size_t dim) {
+	tests_total += 1;
+	bool passed = true;
+	for (i; 0 ~ dim) ip[i] = 0xdeadbeef;
+	for (i; 0 ~ dim) passed = passed &&  (ip[i] == 0xdeadbeef);
+	if (!passed) {
+		printf("failed test %3d: use int\n", tests_total);
+//		if (last_failed != tests_total) {
+			tests_failed += 1;
+//			last_failed = tests_total;
+//		}
+	}
+}
+
+void test_use( T1 * ip, size_t dim) {
+	tests_total += 1;
+	bool passed = true;
+	for (i; 0 ~ dim) ip[i].data = 0xdeadbeef;
+	for (i; 0 ~ dim) passed = passed &&  (ip[i].data == 0xdeadbeef);
+	if (!passed) {
+		printf("failed test %3d: use T1\n", tests_total);
+//		if (last_failed != tests_total) {
+			tests_failed += 1;
+//			last_failed = tests_total;
+//		}
+	}
+}
+
+int main( void ) {
+	size_t elemSize = sizeof(int);
+	size_t dim = 8;
+	size_t size = dim * elemSize;
+	size_t align = 64;
+	const size_t libAlign = libAlign();
+
+	int 	FillT = 9;
+	char 	FillC = 'a';
+	int   * FillA = calloc(dim / 4);
+	T1 	    FillT1 = { FillT };
+	T1 	  * FillT1A = (T1 *)(void *) malloc( (dim / 4) * sizeof(T1) );
+	for (i; 0 ~ (dim / 4) ) FillT1A[i] = FillT1;
+
+	int		* ip;
+	int 	* op;
+	double 	* dp;
+	T1      * t1p;
+	T1 	    * t1op;
+
+	// testing alloc
+
+	last_failed = -1;
+	tests_total = 0;
+	tests_failed = 0;
+
+	ip = alloc();
+	test_base(ip, elemSize, libAlign);
+	test_use(ip, elemSize / elemSize);
+	free(ip);
+
+	ip = alloc( dim );
+	test_base(ip, size, libAlign);
+	test_use(ip, size / elemSize);
+	free(ip);
+
+	ip = alloc( 0 );
+	test_base(ip, 0, libAlign);
+	free(ip);
+
+	dp = alloc( dim );
+	ip = alloc( dp`resize );
+	test_base(ip, elemSize, libAlign);
+	test_use(ip, elemSize / elemSize);
+	free(ip);
+
+	ip = alloc( ((double*)0p)`resize );
+	test_base(ip, elemSize, libAlign);
+	test_use(ip, elemSize / elemSize);
+	free(ip);
+
+	dp = alloc( dim );
+	ip = alloc( dim, dp`resize );
+	test_base(ip, size, libAlign);
+	test_use(ip, size / elemSize);
+	free(ip);
+
+	dp = alloc( dim );
+	ip = alloc( 0, dp`resize );
+	test_base(ip, 0, libAlign);
+	free(ip);
+
+	ip = alloc( dim, ((double*)0p)`resize );
+	test_base(ip, size, libAlign);
+	test_use(ip, size / elemSize);
+	free(ip);
+
+	ip = alloc( 0, ((double*)0p)`resize );
+	test_base(ip, 0, libAlign);
+	free(ip);
+
+	op = alloc( dim, ((int)0xdeadbeef)`fill );
+	ip = alloc( dim, op`realloc );
+	test_base(ip, size, libAlign);
+	test_fill(ip, 0, dim, (int)0xdeadbeef);
+	test_use(ip, size / elemSize);
+	free(ip);
+
+	op = alloc( dim, ((int)0xdeadbeef)`fill );
+	ip = alloc( 0, op`realloc );
+	test_base(ip, 0, libAlign);
+	free(ip);
+
+	ip = alloc( dim, ((int*)0p)`realloc );
+	test_base(ip, size, libAlign);
+	test_use(ip, size / elemSize);
+	free(ip);
+
+	ip = alloc( 0, ((int*)0p)`realloc );
+	test_base(ip, 0, libAlign);
+	free(ip);
+
+	op = alloc( dim, ((int)0xdeadbeef)`fill );
+	ip = alloc( dim, op`resize );
+	test_base(ip, size, libAlign);
+	test_use(ip, size / elemSize);
+	free(ip);
+
+	ip = alloc( FillC`fill );
+	test_base(ip, elemSize, libAlign);
+	test_fill(ip, 0, elemSize, FillC);
+	test_use(ip, elemSize / elemSize);
+	free(ip);
+
+	ip = alloc( FillT`fill );
+	test_base(ip, elemSize, libAlign);
+	test_fill(ip, 0, 1, FillT);
+	test_use(ip, elemSize / elemSize);
+	free(ip);
+
+	ip = alloc( dim, FillC`fill );
+	test_base(ip, size, libAlign);
+	test_fill(ip, 0, size, FillC);
+	test_use(ip, size / elemSize);
+	free(ip);
+
+	ip = alloc( 0, FillC`fill );
+	test_base(ip, 0, libAlign);
+	free(ip);
+
+	ip = alloc( dim, FillT`fill );
+	test_base(ip, size, libAlign);
+	test_fill(ip, 0, dim, FillT);
+	test_use(ip, size / elemSize);
+	free(ip);
+
+	ip = alloc( 0, FillT`fill );
+	test_base(ip, 0, libAlign);
+	free(ip);
+
+	ip = alloc( dim, [FillA, dim/4]`fill );
+	test_base(ip, size, libAlign);
+	test_fill(ip, 0, size/4, FillA);
+	test_use(ip, size / elemSize);
+	free(ip);
+
+	ip = alloc( 0, [FillA, dim/4]`fill );
+	test_base(ip, 0, libAlign);
+	free(ip);
+
+	op = alloc( dim, ((int)0xdeadbeef)`fill );
+	ip = alloc( dim, op`realloc, FillC`fill );
+	test_base(ip, size, libAlign);
+	test_fill(ip, 0, dim, (int)0xdeadbeef);
+	test_use(ip, size / elemSize);
+	free(ip);
+
+	op = alloc( dim, ((int)0xdeadbeef)`fill );
+	ip = alloc( dim / 4, op`realloc, FillC`fill );
+	test_base(ip, size / 4, libAlign);
+	test_fill(ip, 0, dim / 4, (int)0xdeadbeef);
+	test_use(ip, size / 4 / elemSize);
+	free(ip);
+
+	op = alloc( dim, ((int)0xdeadbeef)`fill );
+	ip = alloc( dim * 4, op`realloc, FillC`fill );
+	test_base(ip, size * 4, libAlign);
+	test_fill(ip, 0, dim, (int)0xdeadbeef);
+	test_fill(ip, size, size * 4, FillC);
+	test_use(ip, size * 4 / elemSize);
+	free(ip);
+
+	op = alloc( dim, ((int)0xdeadbeef)`fill );
+	ip = alloc( 0, op`realloc, FillC`fill );
+	test_base(ip, 0, libAlign);
+	free(ip);
+
+	ip = alloc( dim, ((int*)0p)`realloc, FillC`fill );
+	test_base(ip, size, libAlign);
+	test_fill(ip, 0, size, FillC);
+	test_use(ip, size / elemSize);
+	free(ip);
+
+	ip = alloc( 0, ((int*)0p)`realloc, FillC`fill );
+	test_base(ip, 0, libAlign);
+	free(ip);
+
+	op = alloc( dim, ((int)0xdeadbeef)`fill );
+	ip = alloc( dim, op`realloc, FillT`fill );
+	test_base(ip, size, libAlign);
+	test_fill(ip, 0, dim, (int)0xdeadbeef);
+	test_use(ip, size / elemSize);
+	free(ip);
+
+	op = alloc( dim, ((int)0xdeadbeef)`fill );
+	ip = alloc( dim / 4, op`realloc, FillT`fill );
+	test_base(ip, size / 4, libAlign);
+	test_fill(ip, 0, dim / 4, (int)0xdeadbeef);
+	test_use(ip, size / 4 / elemSize);
+	free(ip);
+
+	op = alloc( dim, ((int)0xdeadbeef)`fill );
+	ip = alloc( dim * 4, op`realloc, FillT`fill );
+	test_base(ip, size * 4, libAlign);
+	test_fill(ip, 0, dim, (int)0xdeadbeef);
+	test_fill(ip, dim, dim * 4, FillT);
+	test_use(ip, size * 4 / elemSize);
+	free(ip);
+
+	op = alloc( dim, ((int)0xdeadbeef)`fill );
+	ip = alloc( 0, op`realloc, FillT`fill );
+	test_base(ip, 0, libAlign);
+	free(ip);
+
+	ip = alloc( dim, ((int*)0p)`realloc, FillT`fill );
+	test_base(ip, size, libAlign);
+	test_fill(ip, 0, dim, FillT);
+	test_use(ip, size / elemSize);
+	free(ip);
+
+//	ip = alloc( 0, ((int*)0p)`realloc, FillT`fill );
+//	est_base(ip, 0, libAlign);
+//	free(ip);
+
+	ip = alloc( align`align );
+	test_base(ip, elemSize, align);
+	test_use(ip, elemSize / elemSize);
+	free(ip);
+
+	ip = alloc( dim, align`align );
+	test_base(ip, size, align);
+	test_use(ip, size / elemSize);
+	free(ip);
+
+	ip = alloc( 0, align`align );
+	test_base(ip, 0, libAlign);
+	free(ip);
+
+	op = alloc( dim, ((int)0xdeadbeef)`fill );
+	ip = alloc( op`realloc, align`align );
+	test_base(ip, elemSize, align);
+	test_fill(ip, 0, 1, (int)0xdeadbeef);
+	test_use(ip, elemSize / elemSize);
+	free(ip);
+
+//	ip = alloc( ((int*)0p)`realloc, align`align );
+//	est_base(ip, elemSize, align);
+//	est_use(ip, elemSize / elemSize);
+//	free(ip);
+
+	dp = alloc( dim );
+	ip = alloc( dp`resize, align`align );
+	test_base(ip, elemSize, align);
+	test_use(ip, elemSize / elemSize);
+	free(ip);
+
+//	ip = alloc( ((double*)0p)`resize, align`align );
+//	est_base(ip, elemSize, align);
+//	est_use(ip, elemSize / elemSize);
+//	free(ip);
+
+	op = alloc( dim, ((int)0xdeadbeef)`fill);
+	ip = alloc( dim, op`realloc, align`align );
+	test_base(ip, size, align);
+	test_fill(ip, 0, dim, (int)0xdeadbeef);
+	test_use(ip, size / elemSize);
+	free(ip);
+
+	op = alloc( dim, ((int)0xdeadbeef)`fill );
+	ip = alloc( 0, op`realloc, align`align );
+	test_base(ip, 0, libAlign);
+	free(ip);
+
+//	ip = alloc( dim, ((int*)0p)`realloc, align`align );
+//	est_base(ip, size, align);
+//	est_use(ip, size / elemSize);
+//	free(ip);
+
+//	ip = alloc( 0, ((int*)0p)`realloc, align`align );
+//	est_base(ip, 0, align);
+//	free(ip);
+
+	ip = alloc( align`align, FillC`fill );
+	test_base(ip, elemSize, align);
+	test_fill(ip, 0, elemSize, FillC);
+	test_use(ip, elemSize / elemSize);
+	free(ip);
+
+	ip = alloc( align`align, FillT`fill );
+	test_base(ip, elemSize, align);
+	test_fill(ip, 0, 1, FillT);
+	test_use(ip, elemSize / elemSize);
+	free(ip);
+
+	ip = alloc( dim, align`align, FillC`fill );
+	test_base(ip, size, align);
+	test_fill(ip, 0, size, FillC);
+	test_use(ip, size / elemSize);
+	free(ip);
+
+	ip = alloc( 0, align`align, FillC`fill );
+	test_base(ip, 0, libAlign);
+	free(ip);
+
+	ip = alloc( dim, align`align, FillT`fill );
+	test_base(ip, size, align);
+	test_fill(ip, 0, dim, FillT);
+	test_use(ip, size / elemSize);
+	free(ip);
+
+	ip = alloc( 0, align`align, FillT`fill );
+	test_base(ip, 0, libAlign);
+	free(ip);
+
+	ip = alloc( dim, align`align, [FillA, dim/4]`fill );
+	test_base(ip, size, align);
+	test_fill(ip, 0, size/4, FillA);
+	test_use(ip, size / elemSize);
+	free(ip);
+
+	ip = alloc( 0, align`align, [FillA, dim/4]`fill );
+	test_base(ip, 0, libAlign);
+	free(ip);
+
+	op = alloc( dim, ((int)0xdeadbeef)`fill );
+	ip = alloc( dim, op`realloc, align`align, FillC`fill );
+	test_base(ip, size, align);
+	test_fill(ip, 0, dim, (int)0xdeadbeef);
+	test_use(ip, size / elemSize);
+	free(ip);
+
+	op = alloc( dim, ((int)0xdeadbeef)`fill );
+	ip = alloc( dim / 4, op`realloc, align`align, FillC`fill );
+	test_base(ip, size / 4, align);
+	test_fill(ip, 0, dim / 4, (int)0xdeadbeef);
+	test_use(ip, size / 4 / elemSize);
+	free(ip);
+
+	op = alloc( dim, ((int)0xdeadbeef)`fill );
+	ip = alloc( dim * 4, op`realloc, align`align, FillC`fill );
+	test_base(ip, size * 4, align);
+	test_fill(ip, 0, dim, (int)0xdeadbeef);
+	test_fill(ip, size, size * 4, FillC);
+	test_use(ip, size * 4 / elemSize);
+	free(ip);
+
+	op = alloc( dim, ((int)0xdeadbeef)`fill );
+	ip = alloc( 0, op`realloc, align`align, FillC`fill );
+	test_base(ip, 0, libAlign);
+	free(ip);
+
+//	ip = alloc( dim, ((int*)0p)`realloc, align`align, FillC`fill );
+//	est_base(ip, size, align);
+//	est_fill(ip, 0, size, FillC);
+//	est_use(ip, size / elemSize);
+//	free(ip);
+
+//	ip = alloc( 0, ((int*)0p)`realloc, align`align, FillC`fill );
+//	est_base(ip, 0, align);
+//	free(ip);
+
+	op = alloc( dim, ((int)0xdeadbeef)`fill );
+	ip = alloc( dim, op`realloc, align`align, FillT`fill );
+	test_base(ip, size, align);
+	test_fill(ip, 0, dim, (int)0xdeadbeef);
+	test_use(ip, size / elemSize);
+	free(ip);
+
+	op = alloc( dim, ((int)0xdeadbeef)`fill );
+	ip = alloc( dim / 4, op`realloc, align`align, FillT`fill );
+	test_base(ip, size / 4, align);
+	test_fill(ip, 0, dim / 4, (int)0xdeadbeef);
+	test_use(ip, size / 4 / elemSize);
+	free(ip);
+
+	op = alloc( dim, ((int)0xdeadbeef)`fill );
+	ip = alloc( dim * 4, op`realloc, align`align, FillT`fill );
+	test_base(ip, size * 4, align);
+	test_fill(ip, 0, dim, (int)0xdeadbeef);
+	test_fill(ip, dim, dim * 4, FillT);
+	test_use(ip, size * 4 / elemSize);
+	free(ip);
+
+	op = alloc( dim, ((int)0xdeadbeef)`fill );
+	ip = alloc( 0, op`realloc, align`align, FillT`fill );
+	test_base(ip, 0, libAlign);
+	free(ip);
+
+//	ip = alloc( dim, ((int*)0p)`realloc, align`align, FillT`fill );
+//	est_base(ip, size, align);
+//	est_fill(ip, 0, dim, FillT);
+//	est_use(ip, size / elemSize);
+//	free(ip);
+
+//	ip = alloc( 0, ((int*)0p)`realloc, align`align, FillT`fill );
+//	est_base(ip, 0, align);
+//	free(ip);
+
+	if (tests_failed == 0) printf("PASSED alloc tests\n\n");
+	else printf("failed alloc tests : %d/%d\n\n", tests_failed, tests_total);
+
+	// testing alloc (aligned struct)
+
+	elemSize = sizeof(T1);
+	size = dim * elemSize;
+	last_failed = -1;
+	tests_total = 0;
+	tests_failed = 0;
+
+	t1p = alloc();
+	test_base(t1p, elemSize, tAlign);
+	test_use(t1p, elemSize / elemSize);
+	free(t1p);
+
+	t1p = alloc( dim );
+	test_base(t1p, size, tAlign);
+	test_use(t1p, size / elemSize);
+	free(t1p);
+
+	t1p = alloc( 0 );
+	test_base(t1p, 0, libAlign);
+	free(t1p);
+
+	dp = alloc( dim );
+	t1p = alloc( dp`resize );
+	test_base(t1p, elemSize, tAlign);
+	test_use(t1p, elemSize / elemSize);
+	free(t1p);
+
+	t1p = alloc( ((double*)0p)`resize );
+	test_base(t1p, elemSize, tAlign);
+	test_use(t1p, elemSize / elemSize);
+	free(t1p);
+
+	dp = alloc( dim );
+	t1p = alloc( dim, dp`resize );
+	test_base(t1p, size, tAlign);
+	test_use(t1p, size / elemSize);
+	free(t1p);
+
+	dp = alloc( dim );
+	t1p = alloc( 0, dp`resize );
+	test_base(t1p, 0, libAlign);
+	free(t1p);
+
+	t1p = alloc( dim, ((double*)0p)`resize );
+	test_base(t1p, size, tAlign);
+	test_use(t1p, size / elemSize);
+	free(t1p);
+
+	t1p = alloc( 0, ((double*)0p)`resize );
+	test_base(t1p, 0, libAlign);
+	free(t1p);
+
+	t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
+	t1p = alloc( dim, t1op`realloc );
+	test_base(t1p, size, tAlign);
+	test_fill(t1p, 0, dim, (T1){0xdeadbeef});
+	test_use(t1p, size / elemSize);
+	free(t1p);
+
+	t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
+	t1p = alloc( 0, t1op`realloc );
+	test_base(t1p, 0, libAlign);
+	free(t1p);
+
+	t1p = alloc( dim, ((T1*)0p)`realloc );
+	test_base(t1p, size, tAlign);
+	test_use(t1p, size / elemSize);
+	free(t1p);
+
+	t1p = alloc( 0, ((T1*)0p)`realloc );
+	test_base(t1p, 0, libAlign);
+	free(t1p);
+
+	t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
+	t1p = alloc( dim, t1op`resize );
+	test_base(t1p, size, tAlign);
+	test_use(t1p, size / elemSize);
+	free(t1p);
+
+	t1p = alloc( FillC`fill );
+	test_base(t1p, elemSize, tAlign);
+	test_fill(t1p, 0, elemSize, FillC);
+	test_use(t1p, elemSize / elemSize);
+	free(t1p);
+
+	t1p = alloc( FillT1`fill );
+	test_base(t1p, elemSize, tAlign);
+	test_fill(t1p, 0, 1, FillT1);
+	test_use(t1p, elemSize / elemSize);
+	free(t1p);
+
+	t1p = alloc( dim, FillC`fill );
+	test_base(t1p, size, tAlign);
+	test_fill(t1p, 0, size, FillC);
+	test_use(t1p, size / elemSize);
+	free(t1p);
+
+	t1p = alloc( 0, FillC`fill );
+	test_base(t1p, 0, libAlign);
+	free(t1p);
+
+	t1p = alloc( dim, FillT1`fill );
+	test_base(t1p, size, tAlign);
+	test_fill(t1p, 0, dim, FillT1);
+	test_use(t1p, size / elemSize);
+	free(t1p);
+
+	t1p = alloc( 0, FillT1`fill );
+	test_base(t1p, 0, libAlign);
+	free(t1p);
+
+	t1p = alloc( dim, [FillT1A, dim / 4]`fill );
+	test_base(t1p, size, tAlign);
+	test_fill(t1p, 0, size/4, FillT1A);
+	test_use(t1p, size / elemSize);
+	free(t1p);
+
+	t1p = alloc( 0, [FillT1A, dim / 4]`fill );
+	test_base(t1p, 0, libAlign);
+	free(t1p);
+
+	t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
+	t1p = alloc( dim, t1op`realloc, FillC`fill );
+	test_base(t1p, size, tAlign);
+	test_fill(t1p, 0, dim, (T1){0xdeadbeef});
+	test_use(t1p, size / elemSize);
+	free(t1p);
+
+	t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
+	t1p = alloc( dim / 4, t1op`realloc, FillC`fill );
+	test_base(t1p, size / 4, tAlign);
+	test_fill(t1p, 0, dim / 4, (T1){0xdeadbeef});
+	test_use(t1p, size / 4 / elemSize);
+	free(t1p);
+
+	t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
+	t1p = alloc( dim * 4, t1op`realloc, FillC`fill );
+	test_base(t1p, size * 4, tAlign);
+	test_fill(t1p, 0, dim, (T1){0xdeadbeef});
+	test_fill(t1p, size, size * 4, FillC);
+	test_use(t1p, size * 4 / elemSize);
+	free(t1p);
+
+	t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
+	t1p = alloc( 0, t1op`realloc, FillC`fill );
+	test_base(t1p, 0, libAlign);
+	free(t1p);
+
+	t1p = alloc( dim, ((T1*)0p)`realloc, FillC`fill );
+	test_base(t1p, size, tAlign);
+	test_fill(t1p, 0, size, FillC);
+	test_use(t1p, size / elemSize);
+	free(t1p);
+
+	t1p = alloc( 0, ((T1*)0p)`realloc, FillC`fill );
+	test_base(t1p, 0, libAlign);
+	free(t1p);
+
+	t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
+	t1p = alloc( dim, t1op`realloc, FillT1`fill );
+	test_base(t1p, size, tAlign);
+	test_fill(t1p, 0, dim, (T1){0xdeadbeef});
+	test_use(t1p, size / elemSize);
+	free(t1p);
+
+	t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
+	t1p = alloc( dim / 4, t1op`realloc, FillT1`fill );
+	test_base(t1p, size / 4, tAlign);
+	test_fill(t1p, 0, dim / 4, (T1){0xdeadbeef});
+	test_use(t1p, size / 4 / elemSize);
+	free(t1p);
+
+	t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
+	t1p = alloc( dim * 4, t1op`realloc, FillT1`fill );
+	test_base(t1p, size * 4, tAlign);
+	test_fill(t1p, 0, dim, (T1){0xdeadbeef});
+	test_fill(t1p, dim, dim * 4, FillT1);
+	test_use(t1p, size * 4 / elemSize);
+	free(t1p);
+
+	t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
+	t1p = alloc( 0, t1op`realloc, FillT1`fill );
+	test_base(t1p, 0, libAlign);
+	free(t1p);
+
+	t1p = alloc( dim, ((T1*)0p)`realloc, FillT1`fill );
+	test_base(t1p, size, tAlign);
+	test_fill(t1p, 0, dim, FillT1);
+	test_use(t1p, size / elemSize);
+	free(t1p);
+
+//	t1p = alloc( (T1*)0p, 0, FillT1 );
+//	est_base(t1p, 0, tAlign);
+//	free(t1p);
+
+	t1p = alloc( align`align );
+	test_base(t1p, elemSize, align);
+	test_use(t1p, elemSize / elemSize);
+	free(t1p);
+
+	t1p = alloc( dim, align`align );
+	test_base(t1p, size, align);
+	test_use(t1p, size / elemSize);
+	free(t1p);
+
+	t1p = alloc( 0, align`align );
+	test_base(t1p, 0, libAlign);
+	free(t1p);
+
+	t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
+	t1p = alloc( t1op`realloc, align`align );
+	test_base(t1p, elemSize, align);
+	test_fill(t1p, 0, 1, (T1){0xdeadbeef});
+	test_use(t1p, elemSize / elemSize);
+	free(t1p);
+
+//	t1p = alloc( ((T1*)0p)`realloc, align`align );
+//	est_base(t1p, elemSize, align);
+//	est_use(t1p, elemSize / elemSize);
+//	free(t1p);
+
+	dp = alloc( dim );
+	t1p = alloc( dp`resize, align`align );
+	test_base(t1p, elemSize, align);
+	test_use(t1p, elemSize / elemSize);
+	free(t1p);
+
+//	t1p = alloc( ((double*)0p)`resize, align`align );
+//	est_base(t1p, elemSize, align);
+//	est_use(t1p, elemSize / elemSize);
+//	free(t1p);
+
+	t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
+	t1p = alloc( dim, t1op`realloc, align`align );
+	test_base(t1p, size, align);
+	test_fill(t1p, 0, dim, (T1){0xdeadbeef});
+	test_use(t1p, size / elemSize);
+	free(t1p);
+
+	t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
+	t1p = alloc( 0, t1op`realloc, align`align );
+	test_base(t1p, 0, libAlign);
+	free(t1p);
+
+//	t1p = alloc( dim, ((T1*)0p)`realloc, align`align );
+//	est_base(t1p, size, align);
+//	est_use(t1p, size / elemSize);
+//	free(t1p);
+
+//	t1p = alloc( 0, ((T1*)0p)`realloc, align`align );
+//	est_base(t1p, 0, align);
+//	free(t1p);
+
+	t1p = alloc( align`align, FillC`fill );
+	test_base(t1p, elemSize, align);
+	test_fill(t1p, 0, elemSize, FillC);
+	test_use(t1p, elemSize / elemSize);
+	free(t1p);
+
+	t1p = alloc( align`align, FillT1`fill );
+	test_base(t1p, elemSize, align);
+	test_fill(t1p, 0, 1, FillT1);
+	test_use(t1p, elemSize / elemSize);
+	free(t1p);
+
+	t1p = alloc( dim, align`align, FillC`fill );
+	test_base(t1p, size, align);
+	test_fill(t1p, 0, size, FillC);
+	test_use(t1p, size / elemSize);
+	free(t1p);
+
+	t1p = alloc( 0, align`align, FillC`fill );
+	test_base(t1p, 0, libAlign);
+	free(t1p);
+
+	t1p = alloc( dim, align`align, FillT1`fill );
+	test_base(t1p, size, align);
+	test_fill(t1p, 0, dim, FillT1);
+	test_use(t1p, size / elemSize);
+	free(t1p);
+
+	t1p = alloc( 0, align`align, FillT1`fill );
+	test_base(t1p, 0, libAlign);
+	free(t1p);
+
+	t1p = alloc( dim, align`align, [FillT1A, dim / 4]`fill );
+	test_base(t1p, size, align);
+	test_fill(t1p, 0, size/4, FillT1A);
+	test_use(t1p, size / elemSize);
+	free(t1p);
+
+	t1p = alloc( 0, align`align, [FillT1A, dim / 4]`fill );
+	test_base(t1p, 0, libAlign);
+	free(t1p);
+
+	t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
+	t1p = alloc( dim, t1op`realloc, align`align, FillC`fill );
+	test_base(t1p, size, align);
+	test_fill(t1p, 0, dim, (T1){0xdeadbeef});
+	test_use(t1p, size / elemSize);
+	free(t1p);
+
+	t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
+	t1p = alloc( dim / 4, t1op`realloc, align`align, FillC`fill );
+	test_base(t1p, size / 4, align);
+	test_fill(t1p, 0, dim / 4, (T1){0xdeadbeef});
+	test_use(t1p, size / 4 / elemSize);
+	free(t1p);
+
+	t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
+	t1p = alloc( dim * 4, t1op`realloc, align`align, FillC`fill );
+	test_base(t1p, size * 4, align);
+	test_fill(t1p, 0, dim, (T1){0xdeadbeef});
+	test_fill(t1p, size, size * 4, FillC);
+	test_use(t1p, size * 4 / elemSize);
+	free(t1p);
+
+	t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
+	t1p = alloc( 0, t1op`realloc, align`align, FillC`fill );
+	test_base(t1p, 0, libAlign);
+	free(t1p);
+
+//	t1p = alloc( dim, ((T1*)0p)`realloc, align`align, FillC`fill );
+//	est_base(t1p, size, align);
+//	est_fill(t1p, 0, size, FillC);
+//	est_use(t1p, size / elemSize);
+//	free(t1p);
+
+//	t1p = alloc( 0, ((T1*)0p)`realloc, align`align, FillC`fill );
+//	est_base(t1p, 0, align);
+//	free(t1p);
+
+	t1op = alloc( dim, ((T1){0xdeadbeef})`fill);
+	t1p = alloc( dim, t1op`realloc, align`align, FillT1`fill );
+	test_base(t1p, size, align);
+	test_fill(t1p, 0, dim, (T1){0xdeadbeef});
+	test_use(t1p, size / elemSize);
+	free(t1p);
+
+	t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
+	t1p = alloc( dim / 4, t1op`realloc, align`align, FillT1`fill );
+	test_base(t1p, size / 4, align);
+	test_fill(t1p, 0, dim / 4, (T1){0xdeadbeef});
+	test_use(t1p, size / 4 / elemSize);
+	free(t1p);
+
+	t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
+	t1p = alloc( dim * 4, t1op`realloc, align`align, FillT1`fill );
+	test_base(t1p, size * 4, align);
+	test_fill(t1p, 0, dim, (T1){0xdeadbeef});
+	test_fill(t1p, dim, dim * 4, FillT1);
+	test_use(t1p, size * 4 / elemSize);
+	free(t1p);
+
+	t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
+	t1p = alloc( 0, t1op`realloc, align`align, FillT1`fill );
+	test_base(t1p, 0, libAlign);
+	free(t1p);
+
+//	t1p = alloc( dim, ((T1*)0p)`realloc, align`aling, FillT1`fill );
+//	est_base(t1p, size, align);
+//	est_fill(t1p, 0, dim, FillT1);
+//	est_use(t1p, size / elemSize);
+//	free(t1p);
+
+//	t1p = alloc( 0, ((T1*)0p)`realloc, align`align, FillT1`fill );
+//	est_base(t1p, 0, align);
+//	free(t1p);
+
+	if (tests_failed == 0) printf("PASSED alloc tests (aligned struct)\n\n");
+	else printf("failed alloc tests (aligned struct) : %d/%d\n\n", tests_failed, tests_total);
+
+	printf("(if applicable) alignment error below indicates memory trashing caused by test_use.\n\n");
+	free(FillA);
+	free(FillT1A);
+	return 0;
+} // main
Index: tests/malloc.cfa
===================================================================
--- tests/malloc.cfa	(revision 191a19015ebe9917f03b8a35a5f9e245085378e7)
+++ tests/malloc.cfa	(revision 191a19015ebe9917f03b8a35a5f9e245085378e7)
@@ -0,0 +1,580 @@
+#include <assert.h>
+#include <malloc.h>										// malloc_usable_size
+#include <stdint.h>										// uintptr_t
+#include <stdlib.h>										// posix_memalign
+#include <fstream.hfa>
+#include <stdlib.hfa>									// access C malloc, realloc
+#include <unistd.h>										// getpagesize
+
+int tests_total;
+int tests_failed;
+size_t tAlign = 32;
+struct S1 { int d1; } __attribute__((aligned(32)));
+typedef struct S1 T1;
+
+void test_base( void * ip, size_t size, size_t align) {
+	tests_total += 1;
+	bool passed = (malloc_size(ip) == size) && (malloc_usable_size(ip) >= size) && (malloc_alignment(ip) == align) && ((uintptr_t)ip % align  == 0);
+	if (!passed) {
+		printf("failed test %2d: %4lu %4lu but got %4lu ( %3lu ) %4lu\n", tests_total, size, align, malloc_size(ip), malloc_usable_size(ip), malloc_alignment(ip));
+		tests_failed += 1;
+	}
+}
+
+void test_fill( void * ip_, size_t start, size_t end, char fill) {
+	tests_total += 1;
+	bool passed = true;
+	char * ip = (char *) ip_;
+	for (i; start ~ end) passed = passed && (ip[i] == fill);
+	if (!passed) {
+		printf("failed test %2d: fill\n", tests_total);
+		tests_failed += 1;
+	}
+}
+
+void test_use( void * ip_) {
+	tests_total += 1;
+	bool passed = true;
+	int * ip = (int *) ip_;
+	size_t size = malloc_size(ip);
+	for (i; 0 ~ size ~ sizeof(int)) ip[i/sizeof(int)] = 0xdeadbeef;
+	for (i; 0 ~ size ~ sizeof(int)) passed = passed &&  (ip[i/sizeof(int)] == 0xdeadbeef);
+	size_t usize = malloc_usable_size(ip);
+	for (i; size ~ usize ~ sizeof(int)) ip[i/sizeof(int)] = -1;
+	for (i; size ~ usize ~ sizeof(int)) passed = passed &&  (ip[i/sizeof(int)] == -1);
+	if (!passed) {
+		printf("failed test %2d: use\n", tests_total);
+		tests_failed += 1;
+	}
+}
+
+int main( void ) {
+	size_t elemSize = sizeof(int);
+	size_t dim = 8;
+	size_t size = dim * elemSize;
+	size_t align = 64;
+	const size_t libAlign = libAlign();
+	char fill = '\xde';
+	int * ip;
+	T1 * tp;
+
+	// testing C   malloc
+
+	tests_total = 0;
+	tests_failed = 0;
+
+	ip = (int *) (void *) malloc( size );
+	test_base(ip, size, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) malloc( 0 );
+	test_base(ip, 0, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) aalloc( dim, elemSize );
+	test_base(ip, size, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) aalloc( 0, elemSize );
+	test_base(ip, 0, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) aalloc( dim, 0 );
+	test_base(ip, 0, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) aalloc( 0, 0 );
+	test_base(ip, 0, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) calloc( dim, elemSize );
+	test_base(ip, size, libAlign);
+	test_fill(ip, 0, size, '\0');
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) calloc( 0, elemSize );
+	test_base(ip, 0, libAlign);
+	test_fill(ip, 0, 0, '\0');
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) calloc( dim, 0 );
+	test_base(ip, 0, libAlign);
+	test_fill(ip, 0, 0, '\0');
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) malloc( size );
+	ip = (int *) (void *) resize( (void *) ip, size / 4 );
+	test_base(ip, size / 4, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) malloc( size );
+	ip = (int *) (void *) resize( (void *) ip, size * 4 );
+	test_base(ip, size * 4, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) malloc( size );
+	ip = (int *) (void *) resize( (void *) ip, 0 );
+	test_base(ip, 0, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) resize( NULL, size );
+	test_base(ip, size, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) resize( 0p, size );
+	test_base(ip, size, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) calloc( dim, elemSize );
+	ip = (int *) (void *) realloc( (void *) ip, size / 4 );
+	test_base(ip, size / 4, libAlign);
+	test_fill(ip, 0, size / 4, '\0');
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) calloc( dim, elemSize );
+	ip = (int *) (void *) realloc( (void *) ip, size * 4 );
+	test_base(ip, size * 4, libAlign);
+	test_fill(ip, 0, size * 4, '\0');
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) calloc( dim, elemSize );
+	ip = (int *) (void *) realloc( (void *) ip, 0 );
+	test_base(ip, 0, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) realloc( NULL, size  );
+	test_base(ip, size , libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) realloc( 0p, size );
+	test_base(ip, size, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) memalign( align, size );
+	test_base(ip, size, align);
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) memalign( align, 0 );
+	test_base(ip, 0, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) amemalign( align, dim, elemSize );
+	test_base(ip, size, align);
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) amemalign( align, 0, elemSize );
+	test_base(ip, 0, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) amemalign( align, dim, 0 );
+	test_base(ip, 0, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) cmemalign( align, dim, elemSize );
+	test_base(ip, size, align);
+	test_fill(ip, 0, size, '\0');
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) cmemalign( align, 0, elemSize );
+	test_base(ip, 0, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) cmemalign( align, dim, 0 );
+	test_base(ip, 0, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) aligned_alloc( align, size );
+	test_base(ip, size, align);
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) aligned_alloc( align, 0 );
+	test_base(ip, 0, libAlign);
+	test_use(ip);
+	free(ip);
+
+	(int) posix_memalign( (void **) &ip, align, size );
+	test_base(ip, size, align);
+	test_use(ip);
+	free(ip);
+
+	(int) posix_memalign( (void **) &ip, align, 0 );
+	test_base(ip, 0, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) valloc( size );
+	test_base(ip, size, getpagesize());
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) valloc( 0 );
+	test_base(ip, 0, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) pvalloc( getpagesize() * 3 / 2 );
+	test_base(ip, getpagesize() * 2, getpagesize());
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) pvalloc( 0 );
+	test_base(ip, 0, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) malloc( size );
+	ip = (int *) (void *) resize( (void *) ip, align, size / 4 );
+	test_base(ip, size / 4, align);
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) malloc( size );
+	ip = (int *) (void *) resize( (void *) ip, align, 0 );
+	test_base(ip, 0, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) resize( NULL, align, size );
+	test_base(ip, size, align);
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) resize( 0p, align, size );
+	test_base(ip, size, align);
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) calloc( dim, elemSize );
+	ip = (int *) (void *) realloc( (void *) ip, align, size / 4 );
+	test_base(ip, size / 4, align);
+	test_fill(ip, 0, size / 4, '\0');
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) calloc( dim, elemSize );
+	ip = (int *) (void *) realloc( (void *) ip, 0, size * 4 );
+	test_base(ip, size * 4, libAlign);
+	test_fill(ip, 0, size * 4, '\0');
+	test_use(ip);
+	free(ip);
+
+	ip = (int *) (void *) calloc( dim, elemSize );
+	ip = (int *) (void *) realloc( (void *) ip, align, 0 );
+	test_base(ip, 0, libAlign);
+	test_use(ip);
+	free(ip);
+
+	free( 0p ); // sanity check
+	free( NULL ); // sanity check
+
+	if (tests_failed == 0) printf("PASSED C malloc tests\n\n");
+	else printf("failed C malloc tests : %d/%d\n\n", tests_failed, tests_total);
+
+	// testing CFA malloc
+
+	tests_total = 0;
+	tests_failed = 0;
+
+	ip = malloc();
+	test_base(ip, elemSize, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = aalloc( dim );
+	test_base(ip, size, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = aalloc( 0 );
+	test_base(ip, 0, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = calloc( dim );
+	test_base(ip, size, libAlign);
+	test_fill(ip, 0, size, '\0');
+	test_use(ip);
+	free(ip);
+
+	ip = calloc( 0 );
+	test_base(ip, 0, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = aalloc( dim );
+	ip = resize( ip, size / 4 );
+	test_base(ip, size / 4, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = aalloc( dim );
+	ip = resize( ip, size * 4 );
+	test_base(ip, size * 4, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = aalloc( dim );
+	ip = resize( ip, 0 );
+	test_base(ip, 0, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = resize( NULL, size );
+	test_base(ip, size, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = resize( 0p, size );
+	test_base(ip, size, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = calloc( dim );
+	ip = realloc( ip, size / 4 );
+	test_base(ip, size / 4, libAlign);
+	test_fill(ip, 0, size / 4, '\0');
+	test_use(ip);
+	free(ip);
+
+	ip = calloc( dim );
+	ip = realloc( ip, size * 4 );
+	test_base(ip, size * 4, libAlign);
+	test_fill(ip, 0, size, '\0');
+	test_use(ip);
+	free(ip);
+
+	ip = calloc( dim );
+	ip = realloc( ip, 0 );
+	test_base(ip, 0, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = realloc( NULL, size );
+	test_base(ip, size , libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = realloc( 0p, size );
+	test_base(ip, size, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = memalign( align );
+	test_base(ip, elemSize, align);
+	test_use(ip);
+	free(ip);
+
+	ip = amemalign( align, dim );
+	test_base(ip, size, align);
+	test_use(ip);
+	free(ip);
+
+	ip = amemalign( align, 0 );
+	test_base(ip, 0, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = cmemalign( align, dim );
+	test_base(ip, size, align);
+	test_fill(ip, 0, size, '\0');
+	test_use(ip);
+	free(ip);
+
+	ip = cmemalign( align, 0 );
+	test_base(ip, 0, libAlign);
+	test_use(ip);
+	free(ip);
+
+	ip = aligned_alloc( align );
+	test_base(ip, elemSize, align);
+	test_use(ip);
+	free(ip);
+
+	(int) posix_memalign( (int **) &ip, align );
+	test_base(ip, elemSize, align);
+	test_use(ip);
+	free(ip);
+
+	ip = valloc();
+	test_base(ip, elemSize, getpagesize());
+	test_use(ip);
+	free(ip);
+
+	ip = pvalloc();
+	test_base(ip, getpagesize(), getpagesize());
+	test_use(ip);
+	free(ip);
+
+	if (tests_failed == 0) printf("PASSED CFA malloc tests\n\n");
+	else printf("failed CFA malloc tests : %d/%d\n\n", tests_failed, tests_total);
+
+	// testing CFA malloc
+
+	elemSize = sizeof(T1);
+	size = dim * elemSize;
+	tests_total = 0;
+	tests_failed = 0;
+
+	tp = malloc();
+	test_base(tp, elemSize, tAlign );
+	test_use(tp);
+	free(tp);
+
+	tp = aalloc( dim );
+	test_base(tp, size, tAlign );
+	test_use(tp);
+	free(tp);
+
+	tp = aalloc( 0 );
+	test_base(tp, 0, libAlign);
+	test_use(tp);
+	free(tp);
+
+	tp = calloc( dim );
+	test_base(tp, size, tAlign );
+	test_fill(tp, 0, size, '\0');
+	test_use(tp);
+	free(tp);
+
+	tp = calloc( 0 );
+	test_base(tp, 0, libAlign);
+	test_use(tp);
+	free(tp);
+
+	tp = aalloc( dim );
+	tp = resize( tp, size / 4 );
+	test_base(tp, size / 4, tAlign );
+	test_use(tp);
+	free(tp);
+
+	tp = malloc();
+	tp = resize( tp, size * 4 );
+	test_base(tp, size * 4, tAlign );
+	test_use(tp);
+	free(tp);
+
+	tp = aalloc( dim );
+	tp = resize( tp, 0 );
+	test_base(tp, 0, libAlign);
+	test_use(tp);
+	free(tp);
+
+	tp = resize( NULL, size );
+	test_base(tp, size, tAlign );
+	test_use(tp);
+	free(tp);
+
+	tp = resize( 0p, size );
+	test_base(tp, size, tAlign );
+	test_use(tp);
+	free(tp);
+
+	tp = calloc( dim );
+	tp = realloc( tp, size / 4 );
+	test_base(tp, size / 4, tAlign );
+	test_fill(tp, 0, size / 4, '\0');
+	test_use(tp);
+	free(tp);
+
+	tp = calloc( dim );
+	tp = realloc( tp, size * 4 );
+	test_base(tp, size * 4, tAlign );
+	test_fill(tp, 0, size, '\0');
+	test_use(tp);
+	free(tp);
+
+	tp = calloc( dim );
+	tp = realloc( tp, 0 );
+	test_base(tp, 0, libAlign);
+	test_use(tp);
+	free(tp);
+
+	tp = realloc( NULL, size  );
+	test_base(tp, size , tAlign );
+	test_use(tp);
+	free(tp);
+
+	tp = realloc( 0p, size );
+	test_base(tp, size, tAlign );
+	test_use(tp);
+	free(tp);
+
+	tp = memalign( align );
+	test_base(tp, elemSize, align);
+	test_use(tp);
+	free(tp);
+
+	tp = amemalign( align, dim );
+	test_base(tp, size, align);
+	test_use(tp);
+	free(tp);
+
+	tp = amemalign( align, 0 );
+	test_base(tp, 0, libAlign);
+	test_use(tp);
+	free(tp);
+
+	tp = cmemalign( align, dim );
+	test_base(tp, size, align);
+	test_fill(tp, 0, size, '\0');
+	test_use(tp);
+	free(tp);
+
+	tp = cmemalign( align, 0 );
+	test_base(tp, 0, libAlign);
+	test_use(tp);
+	free(tp);
+
+	tp = aligned_alloc( align );
+	test_base(tp, elemSize, align);
+	test_use(tp);
+	free(tp);
+
+	(int) posix_memalign( (int **) &tp, align );
+	test_base(tp, elemSize, align);
+	test_use(tp);
+	free(tp);
+
+	tp = valloc();
+	test_base(tp, elemSize, getpagesize());
+	test_use(tp);
+	free(tp);
+
+	tp = pvalloc();
+	test_base(tp, getpagesize(), getpagesize());
+	test_use(tp);
+	free(tp);
+
+	if (tests_failed == 0) printf("PASSED CFA malloc tests (aligned struct)\n\n");
+	else printf("failed CFA malloc tests (aligned struct) : %d/%d\n\n", tests_failed, tests_total);
+
+	return 0;
+}
