Skip to content

Instantly share code, notes, and snippets.

@changyeon
Created April 13, 2020 06:09
Show Gist options
  • Save changyeon/d26448049879cb17cb1dac68314906ef to your computer and use it in GitHub Desktop.
Save changyeon/d26448049879cb17cb1dac68314906ef to your computer and use it in GitHub Desktop.
Test
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
char *buf = NULL, *p = NULL;
unsigned long i, page_size = 4096, offset = 0, buf_size = 1UL << 10UL;
setbuf(stdout, NULL);
printf("Call a malloc: %p\n", buf);
buf = malloc(buf_size);
printf("Hello World: %p\n", buf);
for (i = 0; i < (buf_size / page_size); i++) {
offset = page_size * i;
p = buf + offset;
*p = i;
}
free(buf);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment