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++):Index: movejobs.cpp
===================================================================
--- movejobs.cpp (revision 2674)
+++ movejobs.cpp (working copy)
@@ -120,7 +120,7 @@
{
for ( int i = 0; i < blocknum; i++ )
{
- delete MemBlocks[i];
+ delete [] MemBlocks[i];
}
free ( MemBlocks );
}
Index: menus.h
===================================================================
--- menus.h (revision 2674)
+++ menus.h (working copy)
@@ -282,6 +282,10 @@
virtual void recalcPosition( bool resetItemPositions );
public:
+ /**
+ * virtual destructor
+ */
+ virtual ~cMenu() {}
/**
* redraws the menu background, the cursor and all menuitems.
*@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
