jezz Apr 10, 2010 8:40 pm
Subject: Some problems reported by valgrind

Hi,
I like original M.A.X. and I want to help with Reloaded version. I have used valgrind to check memory related problem in svn revision 2674. It reports, that mismatched free()/delete/delete[] was used. Also base class cMenu has virtual methods but it does not have virtual destructor. I have created patch for this two problems.

DownloadSource code (C++):
  1. Index: movejobs.cpp
  2. ===================================================================
  3. --- movejobs.cpp        (revision 2674)
  4. +++ movejobs.cpp        (working copy)
  5. @@ -120,7 +120,7 @@
  6.         {
  7.                 for ( int i = 0; i < blocknum; i++ )
  8.                 {
  9. -                       delete MemBlocks[i];
  10. +                       delete [] MemBlocks[i];
  11.                 }
  12.                 free ( MemBlocks );
  13.         }
  14. Index: menus.h
  15. ===================================================================
  16. --- menus.h     (revision 2674)
  17. +++ menus.h     (working copy)
  18. @@ -282,6 +282,10 @@
  19.         virtual void recalcPosition( bool resetItemPositions );
  20.  
  21.  public:
  22. +   /**
  23. +    * virtual destructor
  24. +    */
  25. +   virtual ~cMenu() {}
  26.         /**
  27.          * redraws the menu background, the cursor and all menuitems.
  28.          *@author alzi

Just wondering - why there is not used STL (e.g. std::vector instead of clist)? And std::swap can be used to swap two values without defining temporary variable (movejobs.cpp).

Thank you for your great work. This game rocks Cool

beko Apr 11, 2010 7:28 pm
Subject: Re: Some problems reported by valgrind

hi jezz and thanks for your feedback. We appreciate patches a lot but the best place would be to open a ticket on our bugtracker (possible with your forum account) so we won't forget to apply the patch as well Wink

Movejobs are Eiko's baby.

Eiko Apr 11, 2010 8:40 pm
Subject: Re: Some problems reported by valgrind

Patch is aplied. Thanks, Jezz. Smiling