Who frees what: ownership
Every heap block needs exactly one owner. Learn borrowed vs owned pointers, create and destroy pairs, and how to catch leaks and double frees by counting.
- The skill
- Decide which code owns each heap block so every block is freed exactly once.
- You make
- Player badges, a playlist with a proper destroy function, a deep copy of a save and a gamer profile that can be renamed.
Premium lesson
£7.99 a month or £59 a year. Cancel any time.
Builds on 20 Growing memory with realloc. Free to try: C Foundations and the playground.
Passed
You can now
Step 1 of 9
exercise_1.c
You've reached the good stuff.
5 exercises in this lesson, checked as you type. Premium opens every lesson after Foundations, in all four courses.
C, 32-bit: int and pointers are 4 bytes