MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / strbuf_resize

Function strbuf_resize

deps/lua/src/strbuf.c:164–180  ·  view source on GitHub ↗

Ensure strbuf can handle a string length bytes long (ignoring NULL * optional termination). */

Source from the content-addressed store, hash-verified

162/* Ensure strbuf can handle a string length bytes long (ignoring NULL
163 * optional termination). */
164void strbuf_resize(strbuf_t *s, int len)
165{
166 int newsize;
167
168 newsize = calculate_new_size(s, len);
169
170 if (s->debug > 1) {
171 fprintf(stderr, "strbuf(%lx) resize: %d => %d\n",
172 (long)s, s->size, newsize);
173 }
174
175 s->size = newsize;
176 s->buf = realloc(s->buf, s->size);
177 if (!s->buf)
178 die("Out of memory");
179 s->reallocs++;
180}
181
182void strbuf_append_string(strbuf_t *s, const char *str)
183{

Callers 3

strbuf_append_stringFunction · 0.85
strbuf_append_fmt_retryFunction · 0.85

Calls 3

calculate_new_sizeFunction · 0.85
reallocFunction · 0.85
dieFunction · 0.85

Tested by

no test coverage detected