We build the malloc() and free() functions from scratch, seeing how memory allocation actually works. This screencast is done entirely in C, but it's OK if you don't know C already; we'll introduce the necessary ideas as we go.



(Nitpicky note: the comment in this screencast about pointers and arrays being "the same" will ruffle experienced C programmers' feathers. The C language does distinguish between arrays and pointers, so the comment is strictly wrong. However, thinking of arrays as being pointers will help new C programmers to understand what's actually happening: arrays are laid out directly in memory, with no extra metadata added, so the address of the array itself is also the address of the first element of the array. Simplifying this to "arrays are lies; they're really just pointers" is easier to grasp for someone who's new to C.)

Malloc From Scratch was published on 2017-11-09. It uses Clang 800.0.42.1, LLVM 8.0.0, and Vim 7.4.2033.