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
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "../starmap.h"
|
#include "../starmap.h"
|
||||||
#include "../menustat.h"
|
#include "../menustat.h"
|
||||||
#include "../controls.h"
|
#include "../controls.h"
|
||||||
@@ -33,7 +36,9 @@ DoStarSearch (MENU_STATE *pMS)
|
|||||||
pss = (STAR_SEARCH_STATE *) HMalloc (sizeof (*pss));
|
pss = (STAR_SEARCH_STATE *) HMalloc (sizeof (*pss));
|
||||||
if (!pss)
|
if (!pss)
|
||||||
return FALSE;
|
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)
|
if (!pss->SortedStars)
|
||||||
{
|
{
|
||||||
HFree (pss);
|
HFree (pss);
|
||||||
@@ -64,7 +69,6 @@ DoStarSearch (MENU_STATE *pMS)
|
|||||||
|
|
||||||
DrawSISMessageEx (pss->Text, -1, -1, DSME_CLEARFR);
|
DrawSISMessageEx (pss->Text, -1, -1, DSME_CLEARFR);
|
||||||
|
|
||||||
HFree (pss->SortedStars);
|
|
||||||
HFree (pss);
|
HFree (pss);
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
|
|||||||
Reference in New Issue
Block a user