-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.c
43 lines (37 loc) · 969 Bytes
/
test.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
#include <stdio.h>
#include <stdlib.h>
#include "memchunk.h"
static void print_chunk_list(struct memchunk *, int, int);
int main(int argc, char ** argv) {
struct memchunk chunklist[9];
int argSize = 9, c, size;
while ((c = getopt(argc, argv, "n:")) != -1) {
switch (c) {
case 'n':
argSize = strtol(optarg, NULL, 10);
break;
default:
break;
}
}
size = get_mem_layout(chunklist, argSize);
printf("Chunks Found: %d Chunks Stored: %d\n", size,
(argSize > size) ? size : argSize);
print_chunk_list(chunklist, argSize, size);
return 0;
}
void print_chunk_list(struct memchunk *chunklist, int size,
int foundSize) {
int i, listSize;
if (size >= foundSize) {
listSize = foundSize;
} else {
listSize = size;
}
for (i=0; i < listSize; i++) {
printf("Start: %-15p Size: %-15lu RW: %d\n",
chunklist[i].start,
chunklist[i].length,
chunklist[i].RW);
}
}