|
-
January 22nd, 2010, 09:12 AM
#10
Re: question on "delete"
 Originally Posted by Speedo
There's no point in the assert, honestly. Calling delete on a null pointer is a no-op so there's no reason to check for that, and if the pointer has already been deleted but not set back to null, the assert isn't going to catch it.
I've assumed that the DELETE macro is used through-out of course, not just sometimes. Then the assert will raise an exception if a pointer is deleted twice. (and even better, if all pointers are systematically initialized to null it will also raise an exception if a pointer was never assigned an object before it was deleted.)
So there's every reason in the world to add the assert. It will alarm you about a bug that would otherwise be passed over in silence. Without the assert the DELETE macro is like pouring perfume on a turd. It just removes the bad smell. But with the assert it becomes a tool in helping you to find and remove the actual turd.
Last edited by nuzzle; January 22nd, 2010 at 10:13 AM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|