3 ms·
Never mind modern systems, malloc() was never a syscall :-) One of the great things about K&R is that it shows you how to implement parts of the C library, incl
by fanf2 6y ago
Never mind modern systems, malloc() was never a syscall :-) One of the great things about K&R is that it shows you how to implement parts of the C library, including a simple malloc(), demonstrating that the library does not need to be magical.
- petr_tik 6y agoThanks you and your parent for pointing this out! I should be more precise, sbrk is the underlying system call that might be invoked inside malloc
- voldacar 6y agommap usually these days
- fanf2 6y agoYes, and often mmap() for large allocations and other parts of the heap. There has been an interesting discussion about memory management in Ritchie’s PDP11 C compiler on the TUHS list this month https://minnie.tuhs.org/pipermail/tuhs/2020-August/thread.html https://minnie.tuhs.org/pipermail/tuhs/2020-August/thread.ht... from the era when large programs could not necessarily afford the overhead of malloc() so sometimes used sbrk() directly.