This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
notes:fall2024:projects:msi2 [2024/09/26 20:47] – [obtain() function] cburling | notes:fall2024:projects:msi2 [2024/09/27 00:23] (current) – [rmlist() function] jmerri10 | ||
---|---|---|---|
Line 60: | Line 60: | ||
With the list now clear, it is time to invoke the rmlist function. This function is simple, and very similar to how rmnode works. Simply call the clearlist function, and then free the memory for which the list was occupying. The last step is to set the now empty, non-memory-occupying list to NULL and return. | With the list now clear, it is time to invoke the rmlist function. This function is simple, and very similar to how rmnode works. Simply call the clearlist function, and then free the memory for which the list was occupying. The last step is to set the now empty, non-memory-occupying list to NULL and return. | ||
+ | It is necessary to remove the list at the end of your game loop to manage memory properly and avoid memory leaks. If you do not remove the list, memory will not be freed and any memory occupied by the nodes you’ve added to the list will accumulate and lead to memory leak/ |