mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-11 06:09:08 -07:00
Merge branch 'zlo/tlsf-and-a-temple-of-memcorrupt' of https://github.com/flipperdevices/flipperzero-firmware into mntm-dev
This commit is contained in:
@@ -435,8 +435,34 @@ void cli_command_free(Cli* cli, FuriString* args, void* context) {
|
||||
printf("Minimum heap size: %zu\r\n", memmgr_get_minimum_free_heap());
|
||||
printf("Maximum heap block: %zu\r\n", memmgr_heap_get_max_free_block());
|
||||
|
||||
printf("Pool free: %zu\r\n", memmgr_pool_get_free());
|
||||
printf("Maximum pool block: %zu\r\n", memmgr_pool_get_max_block());
|
||||
printf("Aux pool total free: %zu\r\n", memmgr_aux_pool_get_free());
|
||||
printf("Aux pool max free block: %zu\r\n", memmgr_pool_get_max_block());
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
void* addr;
|
||||
size_t size;
|
||||
} FreeBlockInfo;
|
||||
|
||||
#define FREE_BLOCK_INFO_MAX 128
|
||||
|
||||
typedef struct {
|
||||
FreeBlockInfo free_blocks[FREE_BLOCK_INFO_MAX];
|
||||
size_t free_blocks_count;
|
||||
} FreeBlockContext;
|
||||
|
||||
static bool free_block_walker(void* pointer, size_t size, bool used, void* context) {
|
||||
FreeBlockContext* free_blocks = (FreeBlockContext*)context;
|
||||
if(!used) {
|
||||
if(free_blocks->free_blocks_count < FREE_BLOCK_INFO_MAX) {
|
||||
free_blocks->free_blocks[free_blocks->free_blocks_count].addr = pointer;
|
||||
free_blocks->free_blocks[free_blocks->free_blocks_count].size = size;
|
||||
free_blocks->free_blocks_count++;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void cli_command_free_blocks(Cli* cli, FuriString* args, void* context) {
|
||||
@@ -444,7 +470,23 @@ void cli_command_free_blocks(Cli* cli, FuriString* args, void* context) {
|
||||
UNUSED(args);
|
||||
UNUSED(context);
|
||||
|
||||
memmgr_heap_printf_free_blocks();
|
||||
FreeBlockContext* free_blocks = malloc(sizeof(FreeBlockContext));
|
||||
free_blocks->free_blocks_count = 0;
|
||||
|
||||
memmgr_heap_walk_blocks(free_block_walker, free_blocks);
|
||||
|
||||
for(size_t i = 0; i < free_blocks->free_blocks_count; i++) {
|
||||
printf(
|
||||
"A %p S %zu\r\n",
|
||||
(void*)free_blocks->free_blocks[i].addr,
|
||||
free_blocks->free_blocks[i].size);
|
||||
}
|
||||
|
||||
if(free_blocks->free_blocks_count == FREE_BLOCK_INFO_MAX) {
|
||||
printf("... and more\r\n");
|
||||
}
|
||||
|
||||
free(free_blocks);
|
||||
}
|
||||
|
||||
void cli_command_i2c(Cli* cli, FuriString* args, void* context) {
|
||||
|
||||
Reference in New Issue
Block a user