diff --git a/sc2/src/uqm/planets/pstarmap-modern.cpp b/sc2/src/uqm/planets/pstarmap-modern.cpp index b30e96118..4033feb1d 100644 --- a/sc2/src/uqm/planets/pstarmap-modern.cpp +++ b/sc2/src/uqm/planets/pstarmap-modern.cpp @@ -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 + #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;