From 3d184952704fa23b553fd64bbf8c55a7350047b1 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 16 Jun 2025 14:55:15 +0200 Subject: [PATCH] ble pool --- esphome/components/esp32_ble/ble_event_pool.h | 6 +++--- esphome/components/esp32_ble/queue_index.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/esphome/components/esp32_ble/ble_event_pool.h b/esphome/components/esp32_ble/ble_event_pool.h index be62de6f08..2c2a86834e 100644 --- a/esphome/components/esp32_ble/ble_event_pool.h +++ b/esphome/components/esp32_ble/ble_event_pool.h @@ -12,11 +12,11 @@ namespace esp32_ble { // BLE Event Pool - On-demand pool of BLEEvent objects to avoid heap fragmentation // Events are allocated on first use and reused thereafter, growing to peak usage -template class BLEEventPool { +template class BLEEventPool { public: BLEEventPool() { // Initialize all slots as unallocated - for (size_t i = 0; i < SIZE; i++) { + for (uint8_t i = 0; i < SIZE; i++) { this->events_[i] = nullptr; } @@ -33,7 +33,7 @@ template class BLEEventPool { ~BLEEventPool() { // Delete any events that were created - for (size_t i = 0; i < SIZE; i++) { + for (uint8_t i = 0; i < SIZE; i++) { if (this->events_[i] != nullptr) { delete this->events_[i]; } diff --git a/esphome/components/esp32_ble/queue_index.h b/esphome/components/esp32_ble/queue_index.h index 99e61cd994..d91f8e6492 100644 --- a/esphome/components/esp32_ble/queue_index.h +++ b/esphome/components/esp32_ble/queue_index.h @@ -10,7 +10,7 @@ namespace esp32_ble { // Lock-free SPSC queue that stores indices instead of pointers // This allows us to use a pre-allocated pool of objects -template class LockFreeIndexQueue { +template class LockFreeIndexQueue { public: static constexpr uint8_t INVALID_INDEX = 0xFF; // 255, which is > MAX_BLE_QUEUE_SIZE (64)