fix: show_alloc_mem() can display detailed info properly

This commit is contained in:
0x35c 2024-09-21 12:19:04 +02:00
parent 943f2beab9
commit deca2b9bfc

View File

@ -2,7 +2,7 @@
#include "kprintf.h" #include "kprintf.h"
// FULL_INFO is to display (or not) both used and unused blocks // FULL_INFO is to display (or not) both used and unused blocks
#define FULL_INFO 0 #define FULL_INFO 1
void show_alloc_mem(void) void show_alloc_mem(void)
{ {
@ -14,19 +14,19 @@ void show_alloc_mem(void)
for (Zone *zone_it = zones[type]; zone_it != NULL; for (Zone *zone_it = zones[type]; zone_it != NULL;
zone_it = zone_it->next) { zone_it = zone_it->next) {
#if FULL_INFO #if FULL_INFO
if (zone_it->kfree) if (zone_it->free)
kprintf("---------- AVAILABLE %s [n°%d - %p] " kprintf("---------- AVAILABLE %s [n°%d - %p] "
"----------\n", "----------\n",
zones_name[type], count, zone_it); zones_name[type], count, zone_it);
for (Block *block_it = zone_it->kfree; block_it != NULL; for (Block *block_it = zone_it->free; block_it != NULL;
block_it = block_it->next_kfree) { block_it = block_it->next_free) {
kprintf("%p - %p : %u bytes\n", block_it->ptr, kprintf("%p - %p : %u bytes\n", block_it->ptr,
(size_t)block_it->ptr + (size_t)block_it->ptr +
block_it->sub_size + sizeof(Block), block_it->sub_size + sizeof(Block),
block_it->sub_size); block_it->sub_size);
} }
if (zone_it->kfree) if (zone_it->free)
ft_printf("\n"); kprintf("\n");
#endif #endif
if (zone_it->used) if (zone_it->used)
kprintf("---------- IN_USE %s [n°%d - %p] " kprintf("---------- IN_USE %s [n°%d - %p] "