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

Function luaL_prepbuffsize

third-party/lua-5.2.4/src/lauxlib.c:437–456  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

435** returns a pointer to a free area with at least 'sz' bytes
436*/
437LUALIB_API char *luaL_prepbuffsize (luaL_Buffer *B, size_t sz) {
438 lua_State *L = B->L;
439 if (B->size - B->n < sz) { /* not enough space? */
440 char *newbuff;
441 size_t newsize = B->size * 2; /* double buffer size */
442 if (newsize - B->n < sz) /* not big enough? */
443 newsize = B->n + sz;
444 if (newsize < B->n || newsize - B->n < sz)
445 luaL_error(L, "buffer too large");
446 /* create larger buffer */
447 newbuff = (char *)lua_newuserdata(L, newsize * sizeof(char));
448 /* move content to new buffer */
449 memcpy(newbuff, B->b, B->n * sizeof(char));
450 if (buffonstack(B))
451 lua_remove(L, -2); /* remove old buffer */
452 B->b = newbuff;
453 B->size = newsize;
454 }
455 return &B->b[B->n];
456}
457
458
459LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) {

Callers 5

str_formatFunction · 0.70
luaL_addlstringFunction · 0.70
luaL_buffinitsizeFunction · 0.70
read_allFunction · 0.70
read_charsFunction · 0.70

Calls 3

luaL_errorFunction · 0.70
lua_newuserdataFunction · 0.70
lua_removeFunction · 0.70

Tested by

no test coverage detected