-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscan.c
40 lines (31 loc) · 794 Bytes
/
scan.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
#include "v2p.h"
#include <sys/mman.h>
#define ALLOC_FLAG (MAP_PRIVATE | MAP_ANONYMOUS)
int main()
{
int n = 1;
int end = 256;
size_t buf_size = ALLOC_SIZE * n + 1;
int i;
for (i=1;i<=end; i++) {
//Alloc memory by "malloc"
char *v = (char*)malloc(buf_size);
//Alloc memory by "stack point"
//char p[100000]; char v=p;
//Alloc memory by "mmap"
//char *v = (char *)mmap(NULL, ALLOC_SIZE * n, PROT_READ | PROT_WRITE, ALLOC_FLAG, -1, 0);
if(v == NULL)
{
printf("Failed to allocate memory for buffer\n");
exit(1);
}
int j;
for(j=1;j<=1000000;j++){
printf("%x",v[j]);
}
//printf("v addr: %p\n", v);
//uint64_t p = v2p(v);
//printf("p addr: %p\n", p);
//printf("%p\n", p);
}
}