Welcome to the Builder Academy

Question case spell hickup - whats wrong ?

More
16 Oct 2017 19:43 #7012 by thomas
You're welcome.

And the reason my way was better is because doing this is a memory leak:
Code:
int foo() { void* data = allocate_data(); if (bar) return; use_data(data); }
After you return in the condition, there no longer exists any way to get a hold of the allocated memory. Thus, it can never be free'd.
In the case of the affect array in your code, this is later added to the character, so it is freed when the character is extracted. But if you skip out before the assignment, but after the allocation, the memory is lost.

Please Log in or Create an account to join the conversation.

Time to create page: 0.338 seconds