mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Don't pass the AppHooks as pointer
It's not permitted to pass a nullptr to the `app_hooks_update`. So a reference should be used. CppCheck says one shouldn't take pointer to a temporary.
This commit is contained in:
parent
b17c2fb80f
commit
977bf5c0d1
3 changed files with 5 additions and 8 deletions
|
|
@ -76,11 +76,9 @@ static AppHooks default_ah = ah;
|
|||
// register the specified hook function pointers. any of them that
|
||||
// are non-zero override the previous function pointer value
|
||||
// (these default to the stub hooks which are functional but basic).
|
||||
void app_hooks_update(AppHooks* new_ah)
|
||||
void app_hooks_update(const AppHooks& new_ah)
|
||||
{
|
||||
ENSURE(new_ah);
|
||||
|
||||
#define OVERRIDE_IF_NONZERO(HOOKNAME) if(new_ah->HOOKNAME) ah.HOOKNAME = new_ah->HOOKNAME;
|
||||
#define OVERRIDE_IF_NONZERO(HOOKNAME) if(new_ah.HOOKNAME) ah.HOOKNAME = new_ah.HOOKNAME;
|
||||
OVERRIDE_IF_NONZERO(get_log_dir)
|
||||
OVERRIDE_IF_NONZERO(bundle_logs)
|
||||
OVERRIDE_IF_NONZERO(display_error)
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ struct AppHooks
|
|||
* override the previous function pointer value
|
||||
* (these default to the stub hooks which are functional but basic).
|
||||
**/
|
||||
void app_hooks_update(AppHooks* ah);
|
||||
void app_hooks_update(const AppHooks& ah);
|
||||
|
||||
/**
|
||||
* was the app hook changed via app_hooks_update from its default value?
|
||||
|
|
|
|||
|
|
@ -208,12 +208,11 @@ void InitVfs(const CmdLineArgs& args)
|
|||
psSetLogDir(logs);
|
||||
// desired location for crashlog is now known. update AppHooks ASAP
|
||||
// (particularly before the following error-prone operations):
|
||||
AppHooks hooks{
|
||||
app_hooks_update({
|
||||
.get_log_dir = psLogDir,
|
||||
.bundle_logs = psBundleLogs,
|
||||
.display_error = psDisplayError
|
||||
};
|
||||
app_hooks_update(&hooks);
|
||||
});
|
||||
|
||||
g_VFS = CreateVfs();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue