Download MetaTrader 5

object deletion in CArrayObj and CList

To add comments, please log in or register
williamwong
632
williamwong  

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
Alexey Da
Moderator
6586
Alexey Da  

Thank you.

Please wait for new build.

To add comments, please log in or register