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

This commit is contained in:
Andrew Tridgell 2024-05-27 11:24:11 +10:00
parent d3133b8fa1
commit 9caf942c7e
4 changed files with 5 additions and 5 deletions

View File

@ -348,7 +348,7 @@ AP_HAL::AnalogSource *AnalogIn::channel(int16_t ardupin)
for (uint8_t j = 0; j < ANALOG_MAX_CHANNELS; j++) {
if (_channels[j] == nullptr) {
_channels[j] = new AnalogSource(ardupin,gpioAdcPin, scaler,0.0f,1);
_channels[j] = NEW_NOTHROW AnalogSource(ardupin,gpioAdcPin, scaler,0.0f,1);
if (ardupin != ANALOG_INPUT_NONE) {
DEV_PRINTF("AnalogIn: channel:%d attached to ardupin:%d at adc1_offset:%d on gpio:%d\n",\

View File

@ -124,7 +124,7 @@ AP_HAL::Device::PeriodicHandle DeviceBus::register_periodic_callback(uint32_t pe
xTaskCreate(DeviceBus::bus_thread, name, Scheduler::DEVICE_SS,
this, thread_priority, &bus_thread_handle);
}
DeviceBus::callback_info *callback = new DeviceBus::callback_info;
DeviceBus::callback_info *callback = NEW_NOTHROW DeviceBus::callback_info;
if (callback == nullptr) {
return nullptr;
}

View File

@ -159,7 +159,7 @@ I2CDeviceManager::get_device(uint8_t bus, uint8_t address,
if (bus >= ARRAY_SIZE(i2c_bus_desc)) {
return AP_HAL::OwnPtr<AP_HAL::I2CDevice>(nullptr);
}
auto dev = AP_HAL::OwnPtr<AP_HAL::I2CDevice>(new I2CDevice(bus, address, bus_clock, use_smbus, timeout_ms));
auto dev = AP_HAL::OwnPtr<AP_HAL::I2CDevice>(NEW_NOTHROW I2CDevice(bus, address, bus_clock, use_smbus, timeout_ms));
return dev;
}

View File

@ -220,7 +220,7 @@ SPIDeviceManager::get_device(const char *name)
#endif
if (busp == nullptr) {
// create a new one
busp = new SPIBus(desc.bus);
busp = NEW_NOTHROW SPIBus(desc.bus);
if (busp == nullptr) {
return nullptr;
}
@ -233,6 +233,6 @@ SPIDeviceManager::get_device(const char *name)
printf("%s:%d 444\n", __PRETTY_FUNCTION__, __LINE__);
#endif
return AP_HAL::OwnPtr<AP_HAL::SPIDevice>(new SPIDevice(*busp, desc));
return AP_HAL::OwnPtr<AP_HAL::SPIDevice>(NEW_NOTHROW SPIDevice(*busp, desc));
}