|
We try, whenever possible, to allow the developer to both allocate and deallocate memory in pairs. We strive not to have any unbalanced memory allocation or deallocation. So, if you allocate it, you release it and if you're passed a pointer to memory you haven't allocated then you should not release it.
Of course, there are a couple of exceptions to this rule which we tried to avoid but found difficult. Those are specifically called out in The Be Book, the documentation of the BeOS:
http://www.be.com/documentation/be_book/
Finally, when a program exits, all of its resources are freed up by the kernel (open files are closed, memory freed, semaphores and ports deleted, etc.), though it is better when you do this yourself...
|