MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / newbuffsize

Function newbuffsize

lib/lua/src/lauxlib.c:535–542  ·  view source on GitHub ↗

** Compute new size for buffer 'B', enough to accommodate extra 'sz' ** bytes. (The test for "not big enough" also gets the case when the ** computation of 'newsize' overflows.) */

Source from the content-addressed store, hash-verified

533** computation of 'newsize' overflows.)
534*/
535static size_t newbuffsize (luaL_Buffer *B, size_t sz) {
536 size_t newsize = (B->size / 2) * 3; /* buffer size * 1.5 */
537 if (l_unlikely(MAX_SIZET - sz < B->n)) /* overflow in (B->n + sz)? */
538 return luaL_error(B->L, "buffer too large");
539 if (newsize < B->n + sz) /* not big enough? */
540 newsize = B->n + sz;
541 return newsize;
542}
543
544
545/*

Callers 1

prepbuffsizeFunction · 0.85

Calls 1

luaL_errorFunction · 0.85

Tested by

no test coverage detected