mcheck: add stats, add a comment with test results

My tests have been run on an U-Boot (of older version)
for ARM (64bits).

Signed-off-by: Eugene Uriev <eugeneuriev@gmail.com>
diff --git a/common/mcheck_core.inc.h b/common/mcheck_core.inc.h
index bade035..2f11ac5 100644
--- a/common/mcheck_core.inc.h
+++ b/common/mcheck_core.inc.h
@@ -48,6 +48,13 @@
  * rather in compile-time, by MCHECK_HEAP_PROTECTION macro. That guarantees that
  * we haven't missed first malloc.
  */
+
+/*
+ * Testing
+ *  This library had been successfully tested for U-Boot @ ARM SoC chip / 64bits.
+ *  Proven for both default and pedantic mode: confirms U-Boot to be clean, and catches
+ *  intentional/testing corruptions. Working with malloc_trim is not tested.
+ */
 #ifndef _MCHECKCORE_INC_H
 #define _MCHECKCORE_INC_H      1
 #include "mcheck.h"
@@ -70,6 +77,8 @@
 // avoid problems with BSS at early stage:
 static char mcheck_pedantic_flag __section(".data") = 0;
 static void *mcheck_registry[REGISTRY_SZ] __section(".data") = {0};
+static size_t mcheck_chunk_count __section(".data") = 0;
+static size_t mcheck_chunk_count_max __section(".data") = 0;
 
 typedef unsigned long long mcheck_elem;
 typedef struct {
@@ -102,7 +111,7 @@
 		msg = "bogus mcheck_status, library is buggy\n";
 		break;
 	}
-	printf("\n\nmcheck: %s!!!\n\n", msg);
+	printf("\n\nmcheck: %s!!! [%zu]\n\n", msg, mcheck_chunk_count_max);
 }
 
 static mcheck_abortfunc_t mcheck_abortfunc = &mcheck_default_abort;
@@ -173,6 +182,7 @@
 			break;
 		}
 
+	--mcheck_chunk_count;
 	return (char *)hdr - hdr->aln_skip;
 }
 
@@ -212,6 +222,10 @@
 	for (i = 0; i < CANARY_DEPTH; ++i)
 		tail->elems[i] = MAGICTAIL;
 
+	++mcheck_chunk_count;
+	if (mcheck_chunk_count > mcheck_chunk_count_max)
+		mcheck_chunk_count_max = mcheck_chunk_count;
+
 	for (i = 0; i < REGISTRY_SZ; ++i)
 		if (!mcheck_registry[i]) {
 			mcheck_registry[i] = hdr;
@@ -283,6 +297,8 @@
 			printf("mcheck, WRN: forgetting %p chunk\n", p);
 			mcheck_registry[i] = 0;
 		}
+
+	mcheck_chunk_count = 0;
 }
 #endif
 #endif