MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / setnodevector

Function setnodevector

extlibs/lua/src/ltable.c:436–458  ·  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

434** overflow.
435*/
436static void setnodevector (lua_State *L, Table *t, unsigned int size) {
437 if (size == 0) { /* no elements to hash part? */
438 t->node = cast(Node *, dummynode); /* use common 'dummynode' */
439 t->lsizenode = 0;
440 t->lastfree = NULL; /* signal that it is using dummy node */
441 }
442 else {
443 int i;
444 int lsize = luaO_ceillog2(size);
445 if (lsize > MAXHBITS || (1u << lsize) > MAXHSIZE)
446 luaG_runerror(L, "table overflow");
447 size = twoto(lsize);
448 t->node = luaM_newvector(L, size, Node);
449 for (i = 0; i < (int)size; i++) {
450 Node *n = gnode(t, i);
451 gnext(n) = 0;
452 setnilkey(n);
453 setempty(gval(n));
454 }
455 t->lsizenode = cast_byte(lsize);
456 t->lastfree = gnode(t, size); /* all positions are free */
457 }
458}
459
460
461/*

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