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

Function setnodevector

third-party/lua-5.5.0/src/ltable.c:602–631  ·  view source on GitHub ↗

** Creates an array for the hash part of a table with the given ** size, or reuses the dummy node if size is zero. ** The computation for size overflow is in two steps: the first ** comparison ensures that the shift in the second one does not ** overflow. */

Source from the content-addressed store, hash-verified

600** overflow.
601*/
602static void setnodevector (lua_State *L, Table *t, unsigned size) {
603 if (size == 0) { /* no elements to hash part? */
604 t->node = cast(Node *, dummynode); /* use common 'dummynode' */
605 t->lsizenode = 0;
606 setdummy(t); /* signal that it is using dummy node */
607 }
608 else {
609 int i;
610 int lsize = luaO_ceillog2(size);
611 if (lsize > MAXHBITS || (1 << lsize) > MAXHSIZE)
612 luaG_runerror(L, "table overflow");
613 size = twoto(lsize);
614 if (lsize < LIMFORLAST) /* no 'lastfree' field? */
615 t->node = luaM_newvector(L, size, Node);
616 else {
617 size_t bsize = size * sizeof(Node) + sizeof(Limbox);
618 char *node = luaM_newblock(L, bsize);
619 t->node = cast(Node *, node + sizeof(Limbox));
620 getlastfree(t) = gnode(t, size); /* all positions are free */
621 }
622 t->lsizenode = cast_byte(lsize);
623 setnodummy(t);
624 for (i = 0; i < cast_int(size); i++) {
625 Node *n = gnode(t, i);
626 gnext(n) = 0;
627 setnilkey(n);
628 setempty(gval(n));
629 }
630 }
631}
632
633
634/*

Callers 2

luaH_resizeFunction · 0.70
luaH_newFunction · 0.70

Calls 2

luaO_ceillog2Function · 0.70
luaG_runerrorFunction · 0.70

Tested by

no test coverage detected