11 - Dynamic Memory Allocation
Channel: Ron Wellman
Date: 2021-01-06

In video 11 of our series on rediscovering the C programming language, we'll discuss dynamic memory allocation.  We'll discuss when to use dynamic memory, how to allocate it, and how we can do so in a safer manner. I'll also introduce you to a program called valgrind that will help in determining when we've created a memory leak or used memory dangerously.  Music was downloaded from mixkit.co and is by Lily J.

Code can be found at: https://github.com/ronwellman/rediscover_c

00:18 - static memory allocation vs dynamic memory allocation
02:54 - determine max stack size using /proc
05:10 - max out the stack example
11:18 - dynamic memory allocation functions
16:19 - malloc example
25:17 - free discussion
26:17 - valgrind discussion and usage
31:30 - validate sucessfull allocation
39:05 - discuss the dangers of use-after-free
44:57 - discuss the dangers of double-free
51:16 - discuss calloc and example
53:40 - discuss memset
56:44 - realloc discussion and example
1:05:35 - recap