Index: libcfa/src/heap.cfa
===================================================================
--- libcfa/src/heap.cfa	(revision 58b6d1b3b8da710a22441043f60cb988a2c2e56d)
+++ libcfa/src/heap.cfa	(revision 0e0f128c9f975b8eb3f6b0870c12c639668ef24c)
@@ -10,6 +10,6 @@
 // Created On       : Tue Dec 19 21:58:35 2017
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Tue Jul 31 18:08:50 2018
-// Update Count     : 470
+// Last Modified On : Sat Aug 11 08:22:16 2018
+// Update Count     : 495
 //
 
@@ -75,18 +75,18 @@
 
 
-static _Bool traceHeap = false;
-
-inline _Bool traceHeap() {
+static bool traceHeap = false;
+
+inline bool traceHeap() {
 	return traceHeap;
 } // traceHeap
 
-_Bool traceHeapOn() {
-	_Bool temp = traceHeap;
+bool traceHeapOn() {
+	bool temp = traceHeap;
 	traceHeap = true;
 	return temp;
 } // traceHeapOn
 
-_Bool traceHeapOff() {
-	_Bool temp = traceHeap;
+bool traceHeapOff() {
+	bool temp = traceHeap;
 	traceHeap = false;
 	return temp;
@@ -94,18 +94,18 @@
 
 
-static _Bool checkFree = false;
-
-inline _Bool checkFree() {
+static bool checkFree = false;
+
+inline bool checkFree() {
 	return checkFree;
 } // checkFree
 
-_Bool checkFreeOn() {
-	_Bool temp = checkFree;
+bool checkFreeOn() {
+	bool temp = checkFree;
 	checkFree = true;
 	return temp;
 } // checkFreeOn
 
-_Bool checkFreeOff() {
-	_Bool temp = checkFree;
+bool checkFreeOff() {
+	bool temp = checkFree;
 	checkFree = false;
 	return temp;
@@ -113,18 +113,18 @@
 
 
-// static _Bool traceHeapTerm = false;
-
-// inline _Bool traceHeapTerm() {
+// static bool traceHeapTerm = false;
+
+// inline bool traceHeapTerm() {
 // 	return traceHeapTerm;
 // } // traceHeapTerm
 
-// _Bool traceHeapTermOn() {
-// 	_Bool temp = traceHeapTerm;
+// bool traceHeapTermOn() {
+// 	bool temp = traceHeapTerm;
 // 	traceHeapTerm = true;
 // 	return temp;
 // } // traceHeapTermOn
 
-// _Bool traceHeapTermOff() {
-// 	_Bool temp = traceHeapTerm;
+// bool traceHeapTermOff() {
+// 	bool temp = traceHeapTerm;
 // 	traceHeapTerm = false;
 // 	return temp;
@@ -133,15 +133,13 @@
 
 #ifdef __CFA_DEBUG__
-static unsigned int allocfree;							// running total of allocations minus frees
-static unsigned int appStart;							// storage allocation when application starts
+static unsigned int allocFree;							// running total of allocations minus frees
 
 static void checkUnfreed() {
-	unsigned int total = allocfree - appStart;
-    if ( total != 0 ) {
+    if ( allocFree != 0 ) {
 		// DO NOT USE STREAMS AS THEY MAY BE UNAVAILABLE AT THIS POINT.
 		// char helpText[512];
-		// int len = snprintf( helpText, 512, "CFA warning (UNIX pid:%ld) : program terminating with %u(0x%x) bytes of storage allocated but not freed.\n"
+		// int len = snprintf( helpText, sizeof(helpText), "CFA warning (UNIX pid:%ld) : program terminating with %u(0x%x) bytes of storage allocated but not freed.\n"
 		// 					"Possible cause is unfreed storage allocated by the program or system/library routines called from the program.\n",
-		// 					(long int)getpid(), total, total ); // always print the UNIX pid
+		// 					(long int)getpid(), allocFree, allocFree ); // always print the UNIX pid
 		// __cfaabi_dbg_bits_write( helpText, len );
     } // if
@@ -150,8 +148,9 @@
 extern "C" {
 void heapAppStart() {									// called by __cfaabi_appready_startup
-	appStart = allocfree;
+	allocFree = 0;
 } // heapAppStart
 
 void heapAppStop() {									// called by __cfaabi_appready_startdown
+	fclose( stdin ); fclose( stdout );
 	checkUnfreed();
 } // heapAppStop
@@ -191,5 +190,5 @@
 						#endif // LOCKFREE
 					};
-				} real;
+				} real; // RealHeader
 				struct FakeHeader {
 					#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
@@ -202,6 +201,6 @@
 					uint32_t alignment;					// low-order bits of home/blockSize used for tricks
 					#endif // __ORDER_BIG_ENDIAN__
-				} fake;
-			} kind;
+				} fake; // FakeHeader
+			} kind; // Kind
 	    } header; // Header
 	    char pad[ALIGN - sizeof( Header )];
@@ -264,10 +263,10 @@
 
 #ifdef __CFA_DEBUG__
-static _Bool heapBoot = 0;								// detect recursion during boot
+static bool heapBoot = 0;								// detect recursion during boot
 #endif // __CFA_DEBUG__
 static HeapManager heapManager __attribute__(( aligned (128) )) @= {}; // size of cache line to prevent false sharing
 
 
-static inline _Bool setMmapStart( size_t value ) {
+static inline bool setMmapStart( size_t value ) {
     if ( value < pageSize || bucketSizes[NoBucketSizes - 1] < value ) return true;
     mmapStart = value;									// set global
@@ -363,5 +362,5 @@
 static void printStats() {
     char helpText[512];
-	__cfaabi_dbg_bits_print_buffer( helpText, 512,
+	__cfaabi_dbg_bits_print_buffer( helpText, sizeof(helpText),
 			"\nHeap statistics:\n"
 			"  malloc: calls %u / storage %llu\n"
@@ -389,5 +388,5 @@
 static int printStatsXML( FILE * stream ) {
     char helpText[512];
-    int len = snprintf( helpText, 512,
+    int len = snprintf( helpText, sizeof(helpText),
 						"<malloc version=\"1\">\n"
 						"<heap nr=\"0\">\n"
@@ -433,5 +432,5 @@
 
 
-static inline _Bool setHeapExpand( size_t value ) {
+static inline bool setHeapExpand( size_t value ) {
     if ( heapExpand < pageSize ) return true;
     heapExpand = value;
@@ -440,5 +439,5 @@
 
 
-static inline void checkHeader( _Bool check, const char * name, void * addr ) {
+static inline void checkHeader( bool check, const char * name, void * addr ) {
     if ( unlikely( check ) ) {							// bad address ?
 		abort( "Attempt to %s storage %p with address outside the heap.\n"
@@ -463,5 +462,5 @@
 #define headerAddr( addr ) ((HeapManager.Storage.Header *)( (char *)addr - sizeof(HeapManager.Storage) ))
 
-static inline _Bool headers( const char * name, void * addr, HeapManager.Storage.Header *& header, HeapManager.FreeHeader *& freeElem, size_t & size, size_t & alignment ) with ( heapManager ) {
+static inline bool headers( const char * name, void * addr, HeapManager.Storage.Header *& header, HeapManager.FreeHeader *& freeElem, size_t & size, size_t & alignment ) with ( heapManager ) {
     header = headerAddr( addr );
 
@@ -589,5 +588,5 @@
 	#ifdef __CFA_DEBUG__
     assert( ((uintptr_t)area & (libAlign() - 1)) == 0 ); // minimum alignment ?
-    __atomic_add_fetch( &allocfree, tsize, __ATOMIC_SEQ_CST );
+    __atomic_add_fetch( &allocFree, tsize, __ATOMIC_SEQ_CST );
 	if ( traceHeap() ) {
 		enum { BufferSize = 64 };
@@ -646,9 +645,8 @@
 
 	#ifdef __CFA_DEBUG__
-    __atomic_add_fetch( &allocfree, -size, __ATOMIC_SEQ_CST );
+    __atomic_add_fetch( &allocFree, -size, __ATOMIC_SEQ_CST );
     if ( traceHeap() ) {
-		enum { BufferSize = 64 };
-		char helpText[BufferSize];
-		int len = snprintf( helpText, BufferSize, "Free( %p ) size:%zu\n", addr, size );
+		char helpText[64];
+		int len = snprintf( helpText, sizeof(helpText), "Free( %p ) size:%zu\n", addr, size );
 		__cfaabi_dbg_bits_write( helpText, len );
     } // if
@@ -758,5 +756,5 @@
 		HeapManager.FreeHeader * freeElem;
 		size_t asize, alignment;
-		_Bool mapped __attribute__(( unused )) = headers( "calloc", area, header, freeElem, asize, alignment );
+		bool mapped __attribute__(( unused )) = headers( "calloc", area, header, freeElem, asize, alignment );
 		#ifndef __CFA_DEBUG__
 		// Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero.
@@ -781,5 +779,5 @@
 		HeapManager.FreeHeader * freeElem;
 		size_t asize;
-		_Bool mapped __attribute__(( unused )) = headers( "cmemalign", area, header, freeElem, asize, alignment );
+		bool mapped __attribute__(( unused )) = headers( "cmemalign", area, header, freeElem, asize, alignment );
 		#ifndef __CFA_DEBUG__
 		// Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero.
@@ -826,5 +824,5 @@
 		if ( unlikely( header->kind.real.blockSize & 2 ) ) { // previous request zero fill (calloc/cmemalign) ?
 			assert( (header->kind.real.blockSize & 1) == 0 );
-			_Bool mapped __attribute__(( unused )) = headers( "realloc", area, header, freeElem, asize, alignment );
+			bool mapped __attribute__(( unused )) = headers( "realloc", area, header, freeElem, asize, alignment );
 			#ifndef __CFA_DEBUG__
 			// Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero.
@@ -889,4 +887,5 @@
     } // free
 
+
     int mallopt( int option, int value ) {
 		choose( option ) {
@@ -929,5 +928,5 @@
 
 
-    _Bool malloc_zero_fill( void * addr ) {
+    bool malloc_zero_fill( void * addr ) {
 		if ( unlikely( addr == 0 ) ) return false;		// null allocation is not zero fill
 		HeapManager.Storage.Header * header = (HeapManager.Storage.Header *)( (char *)addr - sizeof(HeapManager.Storage) );
