* @brief Increase the capacity of buffer if cnt is greater than the * remained capacity in the buffer. Otherwise, do nothing. */
| 145 | * remained capacity in the buffer. Otherwise, do nothing. |
| 146 | */ |
| 147 | sonic_force_inline char* Grow(size_t cnt) { |
| 148 | if (sonic_unlikely(top_ + cnt >= buf_ + cap_)) { |
| 149 | if (sonic_unlikely((top_ + cnt) > buf_ + 2 * cap_)) { |
| 150 | cap_ = top_ - buf_ + cnt; |
| 151 | Reserve(cap_ + cap_ / 2); |
| 152 | } else { |
| 153 | Reserve(cap_ * 2); |
| 154 | } |
| 155 | } |
| 156 | sonic_assert(buf_ != NULL); |
| 157 | return top_; |
| 158 | } |
| 159 | |
| 160 | /** |
| 161 | * @brief Get the end of the buffer. |
no outgoing calls
no test coverage detected