AP_OSD: use NEW_NOTHROW for new(std::nothrow)

This commit is contained in:
Andrew Tridgell 2024-05-27 11:24:14 +10:00
parent 7235c146fa
commit a5672b0105
4 changed files with 6 additions and 6 deletions

View File

@ -252,7 +252,7 @@ AP_OSD_Backend *AP_OSD_MAX7456::probe(AP_OSD &osd, AP_HAL::OwnPtr<AP_HAL::Device
return nullptr;
}
AP_OSD_MAX7456 *backend = new AP_OSD_MAX7456(osd, std::move(dev));
AP_OSD_MAX7456 *backend = NEW_NOTHROW AP_OSD_MAX7456(osd, std::move(dev));
if (!backend) {
return nullptr;
}

View File

@ -171,7 +171,7 @@ void AP_OSD_MSP::setup_defaults(void)
AP_OSD_Backend *AP_OSD_MSP::probe(AP_OSD &osd)
{
AP_OSD_MSP *backend = new AP_OSD_MSP(osd);
AP_OSD_MSP *backend = NEW_NOTHROW AP_OSD_MSP(osd);
if (!backend) {
return nullptr;
}

View File

@ -123,7 +123,7 @@ void AP_OSD_MSP_DisplayPort::setup_defaults(void)
AP_OSD_Backend *AP_OSD_MSP_DisplayPort::probe(AP_OSD &osd)
{
AP_OSD_MSP_DisplayPort *backend = new AP_OSD_MSP_DisplayPort(osd);
AP_OSD_MSP_DisplayPort *backend = NEW_NOTHROW AP_OSD_MSP_DisplayPort(osd);
if (!backend) {
return nullptr;
}

View File

@ -52,7 +52,7 @@ void AP_OSD_SITL::load_font(void)
for (uint16_t i=0; i<256; i++) {
const uint8_t *c = &fd->data[i*54];
// each pixel is 4 bytes, RGBA
sf::Uint8 *pixels = new sf::Uint8[char_width * char_height * 4];
sf::Uint8 *pixels = NEW_NOTHROW sf::Uint8[char_width * char_height * 4];
if (!font[i].create(char_width, char_height)) {
AP_HAL::panic("Failed to create texture");
}
@ -125,7 +125,7 @@ void AP_OSD_SITL::update_thread(void)
load_font();
{
WITH_SEMAPHORE(AP::notify().sf_window_mutex);
w = new sf::RenderWindow(sf::VideoMode(video_cols*(char_width+char_spacing)*char_scale,
w = NEW_NOTHROW sf::RenderWindow(sf::VideoMode(video_cols*(char_width+char_spacing)*char_scale,
video_lines*(char_height+char_spacing)*char_scale),
"OSD");
}
@ -194,7 +194,7 @@ bool AP_OSD_SITL::init(void)
AP_OSD_Backend *AP_OSD_SITL::probe(AP_OSD &osd)
{
AP_OSD_SITL *backend = new AP_OSD_SITL(osd);
AP_OSD_SITL *backend = NEW_NOTHROW AP_OSD_SITL(osd);
if (!backend) {
return nullptr;
}