MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / newbuffsize

Function newbuffsize

third-party/lua-5.5.0/src/lauxlib.c:546–556  ·  view source on GitHub ↗

** Compute new size for buffer 'B', enough to accommodate extra 'sz' ** bytes plus one for a terminating zero. */

Source from the content-addressed store, hash-verified

544** bytes plus one for a terminating zero.
545*/
546static size_t newbuffsize (luaL_Buffer *B, size_t sz) {
547 size_t newsize = B->size;
548 if (l_unlikely(sz >= MAX_SIZE - B->n))
549 return cast_sizet(luaL_error(B->L, "resulting string too large"));
550 /* else B->n + sz + 1 <= MAX_SIZE */
551 if (newsize <= MAX_SIZE/3 * 2) /* no overflow? */
552 newsize += (newsize >> 1); /* new size *= 1.5 */
553 if (newsize < B->n + sz + 1) /* not big enough? */
554 newsize = B->n + sz + 1;
555 return newsize;
556}
557
558
559/*

Callers 1

prepbuffsizeFunction · 0.70

Calls 1

luaL_errorFunction · 0.70

Tested by

no test coverage detected