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:
@@ -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; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user