I had a suggestion for the improvement of Irrlicht and how it does memory management.
Currently I noticed that Irrlicht does a reference counting scheme (somewhat manual with grab() and drop()). I would like to propose moving to something somewhat like boost::shared_ptr<> (boost smart pointers found at http://www.boost.org ) in the case of shared heap objects. This would avoid passing flat pointers around and get rid of the potentially dangerous "delete this" paradigm.
Granted I understand, and respect the choice, to minimize external dependencies. At the very least, Irrlicht could leverage the boost::shared_ptr<> techniques to create something like irr::shared_ptr<>
The advantages of this are significant.
1. When using "delete this", the object is deleted but the pointer is not set to NULL. Therefore all subsequent NULL checks fail potentially causing access violations.
2. You can overload the assignment operator and copy constructor to handle all reference counting. Granted there are some pitfalls and perils to this but they are very well documented in the boost project.
3. If you do manage to dereference a pointer that has been deallocated, you can have the option to throw an safe exception instead of causing an access violation.
Of course with any advantage, there are pitfalls...
This would be a massive compatibility breaker for Irrlicht. All flat pointers would have to be wrapped in the shared_pointer causing many things to break. Yikes!
Believe it or not, it's not as bad as it seems. Though the smart use of typedefs, a little bit of time, and some rocking coding music, the refactor actually goes pretty quickly in my experience
Thoughts?
-Mac