Allow detection of genuine memory leaks by ensuring that all cached
data is freed on shutdown.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
return discarded;
}
+/**
+ * Discard all cached data
+ *
+ */
+static void discard_all_cache ( void ) {
+ unsigned int discarded;
+
+ do {
+ discarded = discard_cache();
+ } while ( discarded );
+}
+
/**
* Allocate a memory block
*
.initialise = init_heap,
};
+/**
+ * Discard all cached data on shutdown
+ *
+ */
+static void shutdown_cache ( int booting __unused ) {
+ discard_all_cache();
+}
+
+/** Memory allocator shutdown function */
+struct startup_fn heap_startup_fn __startup_fn ( STARTUP_EARLY ) = {
+ .shutdown = shutdown_cache,
+};
+
#if 0
#include <stdio.h>
/**