-
Notifications
You must be signed in to change notification settings - Fork 0
/
GUIview.c
60 lines (52 loc) · 1.51 KB
/
GUIview.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <stdio.h>
//Steal the inner function used by our mymalloc and myfree functions
void gui_show_array(int *array)
{
int curheader = 1;
printf("+-------------------------------------+\n");
printf("| Total memory space: %d\n", array[0]);
printf("+-------------------------------------+\n");
while (1)
{
int size;
if (array[curheader] > 0)
{
size = array[curheader];
printf("| Free block, size: %d\n", size);
}
else
{
size = -1 * array[curheader];
printf("| Used block, size: %d\n", size);
}
for (int i = curheader + 1; i < curheader + size + 1; i++)
{
if (array[curheader] > 0)
{
if (array[i] == 0)
{
printf("|\n");
}
else
{
printf("| Dead header (size: %d)\n", array[i]);
}
}
else if (array[i] == 999)
{
printf("| Data\n");
}
else if (array[i] == 0)
{
printf("+ - - - - - - - - - - - - - - - - - - +\n");
printf("| Wasted int\n");
}
else
{
printf("| Data (%d)\n", array[i]);
}
}
printf("+-------------------------------------+\n");
if (!inc_header(array, &curheader)) return;
}
}