Skip to content

Commit e5fb891

Browse files
committed
utils: add print_allocations_table
1 parent 3ccf61f commit e5fb891

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

src/utils/utils.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#include <debug.h>
12
#include "utils.h"
3+
#include "leader.h"
24

35
int fun() {
46
struct a as;
@@ -19,3 +21,25 @@ size_t len(char **array) {
1921
}
2022
return l;
2123
}
24+
25+
void print_allocations_table(struct leader_resources *l_r) {
26+
struct allocation_register *a_r = l_r->leader_reg;
27+
printf(" == ALLOCATIONS TABLE == \n"
28+
" : v_address : parts : size\n"
29+
" --- : --------- : ----- : ----\n");
30+
size_t size = 0;
31+
size_t total_size = 0;
32+
for (size_t i = 0; i < a_r->count_alloc; i++) {
33+
size = 0;
34+
for (size_t j = 0; j < a_r->allocs[i]->number_parts; j++) {
35+
size += a_r->allocs[i]->parts[j]->size;
36+
total_size += size;
37+
}
38+
printf("%4zu : %9zu : %5zu : %zu\n"
39+
, i, a_r->allocs[i]->v_address_start, a_r->allocs[i]->number_parts, size);
40+
}
41+
printf(" === ========= ===== ====\n");
42+
printf(" Total size : %zu\n", total_size);
43+
printf(" ==============================\n");
44+
fflush(stdout);
45+
}

0 commit comments

Comments
 (0)