Hello, Array: malloc, free and Manual Bookkeeping

Post 1 of the Dynamic Arrays in C series · Full source code The Problem No One Starts With You have five integers. You put them in an array: 1 int numbers[5] = {10, 20, 30, 40, 50}; Done. C gives you a contiguous chunk of 20 bytes on the stack, indexed from 0 to 4, and life is good. Now your user wants to add a sixth integer. What do you do? You can’t resize a stack array. Its size was baked into the binary at compile time, the compiler saw 5, calculated 20 bytes, and that’s the space your function’s stack frame has. There’s no negotiation. You could declare int numbers[1000] and hope it’s big enough, but hope is not a memory management strategy. ...

May 24, 2026 · 18 min · pablo

What malloc() does not want you to know

Post 1 of 13 — Series: Memory Allocation and Garbage Collection from Scratch Every time you write malloc(128), something apparently magical happens: the runtime hands you a pointer to 128 bytes of memory nobody else is using. You didn’t ask the operating system for permission. You didn’t specify where those bytes should live. They simply appeared. And when you call free(), they vanish back into the void. The magic is a lie. ...

May 24, 2026 · 15 min · pablo