Start doing some C++ memory management.

This commit is contained in:
2024-04-24 19:40:01 -04:00
parent 3918c56a15
commit a40f4e0801
+6 -2
View File
@@ -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;