malloc: Add call counters for malloc, free, realloc
Add counters to track the number of calls to malloc(), free(), and realloc(). These are displayed by the 'malloc info' command and accessible via malloc_get_info(). Co-developed-by: Claude <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com>
This commit is contained in:
@@ -21,8 +21,11 @@ static int do_malloc_info(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||
if (ret)
|
||||
return CMD_RET_FAILURE;
|
||||
|
||||
printf("total bytes = %s\n", format_size(buf, info.total_bytes));
|
||||
printf("in use bytes = %s\n", format_size(buf, info.in_use_bytes));
|
||||
printf("total bytes = %s\n", format_size(buf, info.total_bytes));
|
||||
printf("in use bytes = %s\n", format_size(buf, info.in_use_bytes));
|
||||
printf("malloc count = %lu\n", info.malloc_count);
|
||||
printf("free count = %lu\n", info.free_count);
|
||||
printf("realloc count = %lu\n", info.realloc_count);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user