mirror of
https://github.com/xcat2/xNBA.git
synced 2025-02-19 20:14:34 +00:00
[malloc] Discard all cached data on shutdown
Allow detection of genuine memory leaks by ensuring that all cached data is freed on shutdown. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
parent
838a76a042
commit
df2773193e
@ -144,6 +144,18 @@ static unsigned int discard_cache ( void ) {
|
||||
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
|
||||
*
|
||||
@ -458,6 +470,19 @@ struct init_fn heap_init_fn __init_fn ( INIT_EARLY ) = {
|
||||
.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>
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user