[vtk-developers] Calling foo->Delete() automatically.

Prabhu Ramachandran prabhu at aero.iitm.ernet.in
Fri May 17 23:42:41 EDT 2002


Hi Brad,

>>>>> "BK" == Brad King <brad.king at kitware.com> writes:

    BK> Hello, all: Recently I've been switching often between
    BK> developing VTK classes and developing projects that use smart
    BK> pointers.  As a result, I've created many leaks by forgetting
    BK> to add "foo->Delete()" at all exit points of a method.

    BK> class vtkAutoDelete { public: vtkAutoDelete(vtkObject* obj):
    BK> Object(obj) {} ~vtkAutoDelete() { if(this->Object) {
    BK> this->Object->Delete(); } } private: vtkObject* Object; };

I dont use VTK from C++ but this class sounds good and should be
useful.  Do you think the class needs to be wrapped?  

prabhu



More information about the vtk-developers mailing list