It’ll be fun when you get to funny errors because you used freed memory.
When I was learning about linked lists and decided to use them in a project, I “removed” items by making the previous item’s next point to this item’s next, except I misplaced a call to free before using the fields, and it somehow still worked most of the time on debug builds, but on optimized builds it would cause a segmentation fault 100% of the time.
It’ll be fun when you get to funny errors because you used
free
d memory.When I was learning about linked lists and decided to use them in a project, I “removed” items by making the previous item’s
next
point to this item’snext
, except I misplaced a call tofree
before using the fields, and it somehow still worked most of the time on debug builds, but on optimized builds it would cause a segmentation fault 100% of the time.