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

Function resizebox

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

Resize the buffer used by a box. Optimize for the common case of ** resizing to the old size. (For instance, __gc will resize the box ** to 0 even after it was closed. 'pushresult' may also resize it to a ** final size that is equal to the one set when the buffer was created.) */

Source from the content-addressed store, hash-verified

482** final size that is equal to the one set when the buffer was created.)
483*/
484static void *resizebox (lua_State *L, int idx, size_t newsize) {
485 UBox *box = (UBox *)lua_touserdata(L, idx);
486 if (box->bsize == newsize) /* not changing size? */
487 return box->box; /* keep the buffer */
488 else {
489 void *ud;
490 lua_Alloc allocf = lua_getallocf(L, &ud);
491 void *temp = allocf(ud, box->box, box->bsize, newsize);
492 if (l_unlikely(temp == NULL && newsize > 0)) { /* allocation error? */
493 lua_pushliteral(L, "not enough memory");
494 lua_error(L); /* raise a memory error */
495 }
496 box->box = temp;
497 box->bsize = newsize;
498 return temp;
499 }
500}
501
502
503static int boxgc (lua_State *L) {

Callers 3

boxgcFunction · 0.70
prepbuffsizeFunction · 0.70
luaL_pushresultFunction · 0.70

Calls 3

lua_touserdataFunction · 0.70
lua_getallocfFunction · 0.70
lua_errorFunction · 0.70

Tested by

no test coverage detected