C
You're viewing a free preview. Sign in free to read every script.
Why this exists Every value in C lives somewhere. Locals live on the stack and disappear when the function returns. Anything that must outlive the function, or whose size is not known until run time, lives on the heap ,…
C Basics: Memory Ownership with malloc, calloc, realloc and free
The one question that prevents most memory bugs: who owns this memory and who frees it? Three ownership patterns with real code, the safe realloc idiom, create/destroy pairs, and a leak caught by Valgrind.
Sign in free to read this script, along with the rest of the library.
Sign in free