Reinventing malloc: The First-Principles Journey, Part I

Introduction When you call malloc in C, it just… hands you memory. But how? Where does that memory actually come from? And why do we even need a function like malloc in the first place? To answer that, let’s build our own allocator from scratch. We’ll start from first principles: understand what dynamic memory allocation is, examine the constructs the operating system provides for it, identify which ones can help us reinvent malloc, and eventually settle on sbrk as our tool of choice....

September 13, 2025 · Tarang Ranpara

About this site

Hi 👋, Namaste 🙏, Hello World 🌎!! I’m Tarang, and I welcome you to my humble abode on the vast internet. Once upon a time, I thought of calling this site “Engineer’s Guide to Life” - a manual of sorts, a tidy map to navigate the chaos of code and existence. But as it turns out, life, much like code, refuses to be neatly organized. Bugs show up where you least expect them, refactors happen overnight, and failures are the norm, not the exception....

April 21, 2025 · Tarang Ranpara

About Me

1. Intro Namaste, Hello, Hola, I’m Tarang Ranpara! 👋 Tarang was born in Rajkot and, against all odds, grew up. After his undergrad, he joined ISRO and worked with some of the brightest minds in India, where he learned that “rocket science” is exactly as hard as it sounds but far less dramatic without background music. Later, he pursued his Master’s at DA-IICT, majoring in Machine Learning while also mastering electives like late-night Maggi and debugging code that only breaks during demos....

April 21, 2025 · Tarang Ranpara