MCPcopy Create free account
hub / github.com/bytedance/sonic-cpp / Grow

Method Grow

include/sonic/internal/stack.h:147–158  ·  view source on GitHub ↗

* @brief Increase the capacity of buffer if cnt is greater than the * remained capacity in the buffer. Otherwise, do nothing. */

Source from the content-addressed store, hash-verified

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.

Callers 1

SonicError SerializeImplFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected