1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-25 13:13:48 +01:00

[mdns][openthread] Use StaticVector for services storage with compile-time capacity (#10976)

This commit is contained in:
J. Nick Koston
2025-10-05 15:30:17 -05:00
committed by GitHub
parent 19439199cc
commit 0fd71ca211
7 changed files with 44 additions and 51 deletions

View File

@@ -127,6 +127,16 @@ template<typename T, size_t N> class StaticVector {
}
}
// Return reference to next element and increment count (with bounds checking)
T &emplace_next() {
if (count_ >= N) {
// Should never happen with proper size calculation
// Return reference to last element to avoid crash
return data_[N - 1];
}
return data_[count_++];
}
size_t size() const { return count_; }
bool empty() const { return count_ == 0; }