Understanding Storage Duration, Dynamic Memory, and Building a Custom Vector in C

Storage Duration Categories In C, objects have specific lifetimes determined by their storage duration. There are three primary types: Static Storage Duration: Variables declared outside functions or with static inside functions. They exist for the entire program execution. Automatic Storage Duration: Local variables (typically on the stack). ...

Posted on Sun, 09 Aug 2026 16:25:28 +0000 by jannoy

Dynamic Memory Management in C: malloc, calloc, realloc and Pitfalls

Motivation for Runtime Allocation Automatic variables and fixed-size arrays live on the stack and their sizes are frozen at compile time. When the required amount of data is not known until the program is running, the heap offers a flexible alternative. Core Allocation Routines All prototypes live in <stdlib.h>. malloc void *malloc(size_ ...

Posted on Sat, 01 Aug 2026 16:29:43 +0000 by junrey