object deletion in CArrayObj and CList

 

I use CArrayObj extensively, very often I mix dynamically created objects and automatic created objects, CArrayObj delete the content without checking the pointer type.  To avoid this, I have to turn off freemode at the expense of creating a lot of messy codes just to keep track of the dynamic pointers to delete them properly. 

I am currently extending the 2 classes with my own pointer check so that all my other programmes can safely use CArrayObj without concerning about the pointer deletion. 

I suggest a feature to check the pointer before delete it in CArrayObj and CList. 

if (CheckPointer(ptr)==POINTER_DYNAMIC) delete ptr;

Documentation on MQL5: Standard Constants, Enumerations and Structures / Named Constants / Checking Object Pointer
  • www.mql5.com
Standard Constants, Enumerations and Structures / Named Constants / Checking Object Pointer - Documentation on MQL5
 

Thank you.

Please wait for new build.