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

Function luaL_pushresult

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

Source from the content-addressed store, hash-verified

609
610
611LUALIB_API void luaL_pushresult (luaL_Buffer *B) {
612 lua_State *L = B->L;
613 checkbufferlevel(B, -1);
614 if (!buffonstack(B)) /* using static buffer? */
615 lua_pushlstring(L, B->b, B->n); /* save result as regular string */
616 else { /* reuse buffer already allocated */
617 UBox *box = (UBox *)lua_touserdata(L, -1);
618 void *ud;
619 lua_Alloc allocf = lua_getallocf(L, &ud); /* function to free buffer */
620 size_t len = B->n; /* final string length */
621 char *s;
622 resizebox(L, -1, len + 1); /* adjust box size to content size */
623 s = (char*)box->box; /* final buffer address */
624 s[len] = '\0'; /* add ending zero */
625 /* clear box, as Lua will take control of the buffer */
626 box->bsize = 0; box->box = NULL;
627 lua_pushexternalstring(L, s, len, allocf, ud);
628 lua_closeslot(L, -2); /* close the box */
629 lua_gc(L, LUA_GCSTEP, len);
630 }
631 lua_remove(L, -2); /* remove box or placeholder from the stack */
632}
633
634
635LUALIB_API void luaL_pushresultsize (luaL_Buffer *B, size_t sz) {

Callers 15

writerFunction · 0.70
str_gsubFunction · 0.70
str_formatFunction · 0.70
str_packFunction · 0.70
luaL_tracebackFunction · 0.70
luaL_pushresultsizeFunction · 0.70
luaL_gsubFunction · 0.70
utfcharFunction · 0.70
tconcatFunction · 0.70
setpathFunction · 0.70
pusherrornotfoundFunction · 0.70
searchpathFunction · 0.70

Calls 8

lua_pushexternalstringFunction · 0.85
lua_pushlstringFunction · 0.70
lua_touserdataFunction · 0.70
lua_getallocfFunction · 0.70
resizeboxFunction · 0.70
lua_closeslotFunction · 0.70
lua_gcFunction · 0.70
lua_removeFunction · 0.50

Tested by

no test coverage detected