Start doing some C++ memory management.
This commit is contained in:
@@ -16,6 +16,9 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "../starmap.h"
|
||||
#include "../menustat.h"
|
||||
#include "../controls.h"
|
||||
@@ -33,7 +36,9 @@ DoStarSearch (MENU_STATE *pMS)
|
||||
pss = (STAR_SEARCH_STATE *) HMalloc (sizeof (*pss));
|
||||
if (!pss)
|
||||
return FALSE;
|
||||
pss->SortedStars= (int *) HMalloc( GetStarCount() * sizeof( int * ) );
|
||||
|
||||
std::vector< int > sorted( GetStarCount() ); // Manages the sorted stars memory.
|
||||
pss->SortedStars= sorted.data();
|
||||
if (!pss->SortedStars)
|
||||
{
|
||||
HFree (pss);
|
||||
@@ -64,7 +69,6 @@ DoStarSearch (MENU_STATE *pMS)
|
||||
|
||||
DrawSISMessageEx (pss->Text, -1, -1, DSME_CLEARFR);
|
||||
|
||||
HFree (pss->SortedStars);
|
||||
HFree (pss);
|
||||
|
||||
return success;
|
||||
|
||||
Reference in New Issue
Block a user