Start the long road to exception readiness.

This commit is contained in:
2024-04-24 21:58:14 -04:00
parent 5380bef097
commit bbecfcfd47
2 changed files with 15 additions and 7 deletions
+8 -6
View File
@@ -61,9 +61,15 @@ SortStarsOnName (STAR_SEARCH_STATE *pSS)
} }
// Since HMalloc just terminates on failure,
// we can use `new` safely from mixed C++ and
// C. Either I'll use `std::new_handler` to
// do the same thing... or just let exceptions
// tear it down by bumping into the `noexcept`
// boundaries I'll stick on the `extern "C"`
// interfaces.
extern "C" bool extern "C" bool
DoStarSearch (MENU_STATE *pMS) DoStarSearch (MENU_STATE *pMS) noexcept
try
{ {
TEXTENTRY_STATE tes; TEXTENTRY_STATE tes;
bool success; bool success;
@@ -98,7 +104,3 @@ try
return success; return success;
} }
catch( const std::bad_alloc & )
{
return FALSE;
}
+7 -1
View File
@@ -22,8 +22,14 @@
#include "uqm/menustat.h" #include "uqm/menustat.h"
#include "uqm/controls.h" #include "uqm/controls.h"
#ifndef CXX_NOEXCEPT
#define CXX_NOEXCEPT
#endif
#if defined(__cplusplus) #if defined(__cplusplus)
extern "C" { extern "C" {
#undef CXX_NOEXCEPT
#define CXX_NOEXCEPT noexcept
#endif #endif
extern STAR_DESC *CurStarDescPtr; extern STAR_DESC *CurStarDescPtr;
@@ -65,7 +71,7 @@ typedef struct starsearch_state
int *SortedStars; int *SortedStars;
} STAR_SEARCH_STATE; } STAR_SEARCH_STATE;
bool DoStarSearch( MENU_STATE * ); bool DoStarSearch( MENU_STATE * ) CXX_NOEXCEPT;
BOOLEAN OnStarNameChange( TEXTENTRY_STATE * ); BOOLEAN OnStarNameChange( TEXTENTRY_STATE * );
BOOLEAN OnStarNameFrame ( TEXTENTRY_STATE *pTES ); BOOLEAN OnStarNameFrame ( TEXTENTRY_STATE *pTES );