MCPcopy Create free account
hub / github.com/BigPig0/RelayLive / luaL_prepbuffsize

Function luaL_prepbuffsize

ThirdParty/lua/lua/lauxlib.c:448–467  ·  view source on GitHub ↗

** returns a pointer to a free area with at least 'sz' bytes */

Source from the content-addressed store, hash-verified

446** returns a pointer to a free area with at least 'sz' bytes
447*/
448LUALIB_API char *luaL_prepbuffsize (luaL_Buffer *B, size_t sz) {
449 lua_State *L = B->L;
450 if (B->size - B->n < sz) { /* not enough space? */
451 char *newbuff;
452 size_t newsize = B->size * 2; /* double buffer size */
453 if (newsize - B->n < sz) /* not big enough? */
454 newsize = B->n + sz;
455 if (newsize < B->n || newsize - B->n < sz)
456 luaL_error(L, "buffer too large");
457 /* create larger buffer */
458 newbuff = (char *)lua_newuserdata(L, newsize * sizeof(char));
459 /* move content to new buffer */
460 memcpy(newbuff, B->b, B->n * sizeof(char));
461 if (buffonstack(B))
462 lua_remove(L, -2); /* remove old buffer */
463 B->b = newbuff;
464 B->size = newsize;
465 }
466 return &B->b[B->n];
467}
468
469
470LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) {

Callers 7

str_formatFunction · 0.85
packintFunction · 0.85
str_packFunction · 0.85
luaL_addlstringFunction · 0.85
luaL_buffinitsizeFunction · 0.85
read_allFunction · 0.85
read_charsFunction · 0.85

Calls 2

luaL_errorFunction · 0.85
lua_newuserdataFunction · 0.85

Tested by

no test coverage detected