AP_HAL_Empty: introduce get_HAL_mutable() to complement get_HAL()

Returns a mutable reference to the same HAL for certain purposes where
the HAL needs to be mutated to avoid UB problems with casting away const
and to make the fact that mutation is happening obvious.
This commit is contained in:
Thomas Watson 2023-11-23 19:56:23 -06:00 committed by Peter Barker
parent 2dbf5aefb3
commit db12f428c5
1 changed files with 7 additions and 2 deletions

View File

@ -66,9 +66,14 @@ void HAL_Empty::run(int argc, char* const argv[], Callbacks* callbacks) const
}
}
static HAL_Empty hal_empty;
const AP_HAL::HAL& AP_HAL::get_HAL() {
static const HAL_Empty hal;
return hal;
return hal_empty;
}
AP_HAL::HAL& AP_HAL::get_HAL_mutable() {
return hal_empty;
}
#endif