diff --git a/esphome/components/esp32_ble/ble_event_pool.h b/esphome/components/esp32_ble/ble_event_pool.h index 21f1114608..df92c138c3 100644 --- a/esphome/components/esp32_ble/ble_event_pool.h +++ b/esphome/components/esp32_ble/ble_event_pool.h @@ -42,18 +42,14 @@ template class BLEEventPool { RAMAllocator allocator(RAMAllocator::ALLOC_INTERNAL); event = allocator.allocate(1); - if (event == nullptr) { - // Fall back to regular allocation - event = new BLEEvent(); - } else { + if (event != nullptr) { // Placement new to construct the object new (event) BLEEvent(); + this->total_created_++; } - - this->total_created_++; } - return event; + return event; // Will be nullptr if allocation failed } // Return an event to the pool