| 168 | } |
| 169 | |
| 170 | Pool* addPool(Allocator* allocator) { |
| 171 | if (count_ == capacity_ && !increaseCapacity(allocator)) |
| 172 | return nullptr; |
| 173 | auto pool = &pools_[count_++]; |
| 174 | SlotCount poolCapacity = ARDUINOJSON_POOL_CAPACITY; |
| 175 | if (count_ == maxPools) // last pool is smaller because of NULL_SLOT |
| 176 | poolCapacity--; |
| 177 | pool->create(poolCapacity, allocator); |
| 178 | return pool; |
| 179 | } |
| 180 | |
| 181 | bool increaseCapacity(Allocator* allocator) { |
| 182 | if (capacity_ == maxPools) |