diff --git a/libraries/AP_HAL_ChibiOS/AnalogIn.cpp b/libraries/AP_HAL_ChibiOS/AnalogIn.cpp index 0621162132e..13a06048b12 100644 --- a/libraries/AP_HAL_ChibiOS/AnalogIn.cpp +++ b/libraries/AP_HAL_ChibiOS/AnalogIn.cpp @@ -770,7 +770,7 @@ AP_HAL::AnalogSource* AnalogIn::channel(int16_t pin) WITH_SEMAPHORE(_semaphore); for (uint8_t j=0; j_hanning_window == nullptr || fft->_rfft_data == nullptr || fft->_freq_bins == nullptr || fft->_derivative_freq_bins == nullptr) { delete fft; return nullptr; diff --git a/libraries/AP_HAL_ChibiOS/Device.cpp b/libraries/AP_HAL_ChibiOS/Device.cpp index 619804a4b98..42788f36d85 100644 --- a/libraries/AP_HAL_ChibiOS/Device.cpp +++ b/libraries/AP_HAL_ChibiOS/Device.cpp @@ -134,7 +134,7 @@ AP_HAL::Device::PeriodicHandle DeviceBus::register_periodic_callback(uint32_t pe AP_HAL::panic("Failed to create bus thread %s", name); } } - DeviceBus::callback_info *callback = new DeviceBus::callback_info; + DeviceBus::callback_info *callback = NEW_NOTHROW DeviceBus::callback_info; if (callback == nullptr) { return nullptr; } diff --git a/libraries/AP_HAL_ChibiOS/GPIO.cpp b/libraries/AP_HAL_ChibiOS/GPIO.cpp index f62bd73c27b..15812c9b33f 100644 --- a/libraries/AP_HAL_ChibiOS/GPIO.cpp +++ b/libraries/AP_HAL_ChibiOS/GPIO.cpp @@ -285,14 +285,14 @@ AP_HAL::DigitalSource* GPIO::channel(uint16_t pin) { #if HAL_WITH_IO_MCU if (AP_BoardConfig::io_enabled() && iomcu.valid_GPIO_pin(pin)) { - return new IOMCU_DigitalSource(pin); + return NEW_NOTHROW IOMCU_DigitalSource(pin); } #endif struct gpio_entry *g = gpio_by_pin_num(pin); if (!g) { return nullptr; } - return new DigitalSource(g->pal_line); + return NEW_NOTHROW DigitalSource(g->pal_line); } extern const AP_HAL::HAL& hal; diff --git a/libraries/AP_HAL_ChibiOS/I2CDevice.cpp b/libraries/AP_HAL_ChibiOS/I2CDevice.cpp index f046fdd4979..6a9514df9fc 100644 --- a/libraries/AP_HAL_ChibiOS/I2CDevice.cpp +++ b/libraries/AP_HAL_ChibiOS/I2CDevice.cpp @@ -102,7 +102,7 @@ I2CBus I2CDeviceManager::businfo[ARRAY_SIZE(I2CD)]; void I2CBus::dma_init(void) { chMtxObjectInit(&dma_lock); - dma_handle = new Shared_DMA(I2CD[busnum].dma_channel_tx, I2CD[busnum].dma_channel_rx, + dma_handle = NEW_NOTHROW Shared_DMA(I2CD[busnum].dma_channel_tx, I2CD[busnum].dma_channel_rx, FUNCTOR_BIND_MEMBER(&I2CBus::dma_allocate, void, Shared_DMA *), FUNCTOR_BIND_MEMBER(&I2CBus::dma_deallocate, void, Shared_DMA *)); } @@ -459,7 +459,7 @@ I2CDeviceManager::get_device(uint8_t bus, uint8_t address, if (bus >= ARRAY_SIZE(I2CD)) { return AP_HAL::OwnPtr(nullptr); } - auto dev = AP_HAL::OwnPtr(new I2CDevice(bus, address, bus_clock, use_smbus, timeout_ms)); + auto dev = AP_HAL::OwnPtr(NEW_NOTHROW I2CDevice(bus, address, bus_clock, use_smbus, timeout_ms)); return dev; } diff --git a/libraries/AP_HAL_ChibiOS/RCOutput.cpp b/libraries/AP_HAL_ChibiOS/RCOutput.cpp index 015b0c378fe..0fcc96e04c4 100644 --- a/libraries/AP_HAL_ChibiOS/RCOutput.cpp +++ b/libraries/AP_HAL_ChibiOS/RCOutput.cpp @@ -945,7 +945,7 @@ bool RCOutput::setup_group_DMA(pwm_group &group, uint32_t bitrate, uint32_t bit_ } #else if (!group.dma_handle) { - group.dma_handle = new Shared_DMA(group.dma_up_stream_id, SHARED_DMA_NONE, + group.dma_handle = NEW_NOTHROW Shared_DMA(group.dma_up_stream_id, SHARED_DMA_NONE, FUNCTOR_BIND_MEMBER(&RCOutput::dma_allocate, void, Shared_DMA *), FUNCTOR_BIND_MEMBER(&RCOutput::dma_deallocate, void, Shared_DMA *)); if (!group.dma_handle) { @@ -2565,7 +2565,7 @@ bool RCOutput::set_serial_led_rgb_data(const uint16_t chan, int8_t led, uint8_t for (uint8_t j = 0; j < 4; j++) { delete[] grp->serial_led_data[j]; grp->serial_led_data[j] = nullptr; - grp->serial_led_data[j] = new SerialLed[grp->serial_nleds]; + grp->serial_led_data[j] = NEW_NOTHROW SerialLed[grp->serial_nleds]; if (grp->serial_led_data[j] == nullptr) { // if allocation failed clear all memory for (uint8_t k = 0; k < 4; k++) { diff --git a/libraries/AP_HAL_ChibiOS/RCOutput_bdshot.cpp b/libraries/AP_HAL_ChibiOS/RCOutput_bdshot.cpp index 1138f42b713..801512a687d 100644 --- a/libraries/AP_HAL_ChibiOS/RCOutput_bdshot.cpp +++ b/libraries/AP_HAL_ChibiOS/RCOutput_bdshot.cpp @@ -101,7 +101,7 @@ bool RCOutput::bdshot_setup_group_ic_DMA(pwm_group &group) if (group.dma_ch[i].stream_id == group.dma_up_stream_id) { group.bdshot.ic_dma_handle[i] = group.dma_handle; } else { - group.bdshot.ic_dma_handle[i] = new Shared_DMA(group.dma_ch[i].stream_id, SHARED_DMA_NONE, + group.bdshot.ic_dma_handle[i] = NEW_NOTHROW Shared_DMA(group.dma_ch[i].stream_id, SHARED_DMA_NONE, FUNCTOR_BIND_MEMBER(&RCOutput::bdshot_ic_dma_allocate, void, Shared_DMA *), FUNCTOR_BIND_MEMBER(&RCOutput::bdshot_ic_dma_deallocate, void, Shared_DMA *)); } @@ -165,7 +165,7 @@ bool RCOutput::bdshot_setup_group_ic_DMA(pwm_group &group) group.bdshot.ic_dma_handle[i] = group.dma_handle; } else { // we can use the next channel - group.bdshot.ic_dma_handle[i] = new Shared_DMA(group.dma_ch[curr_chan].stream_id, SHARED_DMA_NONE, + group.bdshot.ic_dma_handle[i] = NEW_NOTHROW Shared_DMA(group.dma_ch[curr_chan].stream_id, SHARED_DMA_NONE, FUNCTOR_BIND_MEMBER(&RCOutput::bdshot_ic_dma_allocate, void, Shared_DMA *), FUNCTOR_BIND_MEMBER(&RCOutput::bdshot_ic_dma_deallocate, void, Shared_DMA *)); } diff --git a/libraries/AP_HAL_ChibiOS/SPIDevice.cpp b/libraries/AP_HAL_ChibiOS/SPIDevice.cpp index 48fd7fcff56..8709f86a823 100644 --- a/libraries/AP_HAL_ChibiOS/SPIDevice.cpp +++ b/libraries/AP_HAL_ChibiOS/SPIDevice.cpp @@ -82,7 +82,7 @@ SPIBus::SPIBus(uint8_t _bus) : chMtxObjectInit(&dma_lock); // allow for sharing of DMA channels with other peripherals - dma_handle = new Shared_DMA(spi_devices[bus].dma_channel_rx, + dma_handle = NEW_NOTHROW Shared_DMA(spi_devices[bus].dma_channel_rx, spi_devices[bus].dma_channel_tx, FUNCTOR_BIND_MEMBER(&SPIBus::dma_allocate, void, Shared_DMA *), FUNCTOR_BIND_MEMBER(&SPIBus::dma_deallocate, void, Shared_DMA *)); @@ -470,7 +470,7 @@ SPIDeviceManager::get_device(const char *name) } if (busp == nullptr) { // create a new one - busp = new SPIBus(desc.bus); + busp = NEW_NOTHROW SPIBus(desc.bus); if (busp == nullptr) { return nullptr; } @@ -480,7 +480,7 @@ SPIDeviceManager::get_device(const char *name) buses = busp; } - return AP_HAL::OwnPtr(new SPIDevice(*busp, desc)); + return AP_HAL::OwnPtr(NEW_NOTHROW SPIDevice(*busp, desc)); } void SPIDeviceManager::set_register_rw_callback(const char* name, AP_HAL::Device::RegisterRWCb cb) diff --git a/libraries/AP_HAL_ChibiOS/UARTDriver.cpp b/libraries/AP_HAL_ChibiOS/UARTDriver.cpp index fd52ea79065..70ee7f2875c 100644 --- a/libraries/AP_HAL_ChibiOS/UARTDriver.cpp +++ b/libraries/AP_HAL_ChibiOS/UARTDriver.cpp @@ -414,7 +414,7 @@ void UARTDriver::_begin(uint32_t b, uint16_t rxS, uint16_t txS) // we only allow for sharing of the TX DMA channel, not the RX // DMA channel, as the RX side is active all the time, so // cannot be shared - dma_handle = new Shared_DMA(sdef.dma_tx_stream_id, + dma_handle = NEW_NOTHROW Shared_DMA(sdef.dma_tx_stream_id, SHARED_DMA_NONE, FUNCTOR_BIND_MEMBER(&UARTDriver::dma_tx_allocate, void, Shared_DMA *), FUNCTOR_BIND_MEMBER(&UARTDriver::dma_tx_deallocate, void, Shared_DMA *)); diff --git a/libraries/AP_HAL_ChibiOS/WSPIDevice.cpp b/libraries/AP_HAL_ChibiOS/WSPIDevice.cpp index ac654919810..49857a09a7e 100644 --- a/libraries/AP_HAL_ChibiOS/WSPIDevice.cpp +++ b/libraries/AP_HAL_ChibiOS/WSPIDevice.cpp @@ -212,7 +212,7 @@ WSPIDeviceManager::get_device(const char *name) } if (busp == nullptr) { // create a new one - busp = new WSPIBus(desc.bus); + busp = NEW_NOTHROW WSPIBus(desc.bus); if (busp == nullptr) { return nullptr; } @@ -222,7 +222,7 @@ WSPIDeviceManager::get_device(const char *name) buses = busp; } - return AP_HAL::OwnPtr(new WSPIDevice(*busp, desc)); + return AP_HAL::OwnPtr(NEW_NOTHROW WSPIDevice(*busp, desc)); } #endif // #if HAL_USE_WSPI == TRUE && defined(HAL_QPI_DEVICE_LIST) diff --git a/libraries/AP_HAL_ChibiOS/shared_dma.cpp b/libraries/AP_HAL_ChibiOS/shared_dma.cpp index 68b86d4b27f..7d72700cf61 100644 --- a/libraries/AP_HAL_ChibiOS/shared_dma.cpp +++ b/libraries/AP_HAL_ChibiOS/shared_dma.cpp @@ -249,7 +249,7 @@ void Shared_DMA::dma_info(ExpandingString &str) { // no buffer allocated, start counting if (_contention_stats == nullptr) { - _contention_stats = new dma_stats[SHARED_DMA_MAX_STREAM_ID+1]; + _contention_stats = NEW_NOTHROW dma_stats[SHARED_DMA_MAX_STREAM_ID+1]; // return zeros on first fetch }