MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / setnodevector

Function setnodevector

lib/lua/src/ltable.c:480–502  ·  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

478** overflow.
479*/
480static void setnodevector (lua_State *L, Table *t, unsigned int size) {
481 if (size == 0) { /* no elements to hash part? */
482 t->node = cast(Node *, dummynode); /* use common 'dummynode' */
483 t->lsizenode = 0;
484 t->lastfree = NULL; /* signal that it is using dummy node */
485 }
486 else {
487 int i;
488 int lsize = luaO_ceillog2(size);
489 if (lsize > MAXHBITS || (1u << lsize) > MAXHSIZE)
490 luaG_runerror(L, "table overflow");
491 size = twoto(lsize);
492 t->node = luaM_newvector(L, size, Node);
493 for (i = 0; i < cast_int(size); i++) {
494 Node *n = gnode(t, i);
495 gnext(n) = 0;
496 setnilkey(n);
497 setempty(gval(n));
498 }
499 t->lsizenode = cast_byte(lsize);
500 t->lastfree = gnode(t, size); /* all positions are free */
501 }
502}
503
504
505/*

Callers 2

luaH_resizeFunction · 0.85
luaH_newFunction · 0.85

Calls 2

luaO_ceillog2Function · 0.85
luaG_runerrorFunction · 0.85

Tested by

no test coverage detected