2 ms·
You can't implement malloc in standard C, but there is no actual C compiler that implements only standard C and provides no other guarantees. There is always im
by TheCoelacanth 8y ago
You can't implement malloc in standard C, but there is no actual C compiler that implements only standard C and provides no other guarantees. There is always implementation defined behavior in addition to what the standard defines.
On Linux, compilers will ensure that you can make system calls to the kernel such as brk[1] or mmap[2] which will let you allocate larger chunks of memory that malloc can split up and give out. On Windows, you will have access to Windows APIs which will let you use VirtualAlloc[3] to do the same.
[1] http://man7.org/linux/man-pages/man2/brk.2.html http://man7.org/linux/man-pages/man2/brk.2.html
[2] http://man7.org/linux/man-pages/man2/mmap.2.html http://man7.org/linux/man-pages/man2/mmap.2.html
[3] https://msdn.microsoft.com/en-us/library/aa366887(VS.85).aspx https://msdn.microsoft.com/en-us/library/aa366887(VS.85).asp...