I want to know how malloc
and free
work.
int main() {
unsigned char *p = (unsigned char*)malloc(4*sizeof(unsigned char));
m
It's also important to realize that simply moving the program break pointer around with brk
and sbrk
doesn't actually allocate the memory, it just sets up the address space. On Linux, for example, the memory will be "backed" by actual physical pages when that address range is accessed, which will result in a page fault, and will eventually lead to the kernel calling into the page allocator to get a backing page.