Signed-off-by: Wenchao Hao <haowenchao22@gmail.com>
This commit is contained in:
Wenchao Hao 2024-09-27 17:34:03 +08:00
commit 7caf6bea2a
1 changed files with 28 additions and 0 deletions

28
demo.c Normal file
View File

@ -0,0 +1,28 @@
#include <stdio.h>
#include <stdlib.h>
#define MB_BYTES (1024*1024)
int main(void)
{
unsigned long *p;
int i = 0;
int nr_mb;
int bytes;
int max;
printf("please specify how many memory to alloc\n");
scanf("%d", &nr_mb);
bytes = nr_mb * MB_BYTES;
max = bytes / 8;
p = malloc(bytes);
for (i = 0; i < max; i++)
*(p + i) = i;
while(1);
return 0;
}