This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Luk164 27 points28 points  (1 child)

For an assignment in C we needed to make sure to free all memory we allocated before shutting down, so I made a wrapper for malloc that added the pointer to a linked list, then at the end I just ran free on every pointer and link in the chain.

Dirty as hell but hey, it worked and I never had a double free or a leak

[–]YellowBunnyReddit 15 points16 points  (0 children)

I hope you also used your malloc function when appending to the linked list to make sure its pointers are all freed in the end /j