void *luaM_growaux (lua_State *L, void *block, size_t nelems, int inc, size_t size, const char *errormsg, size_t limit) { size_t newn = nelems+inc; if (nelems >= limit-inc) lua_error(L, errormsg); if ((newn ^ nelems) <= nelems || /* still the same power-of-2 limit? */ (nelems > 0 && newn < MINPOWER2)) /* or block already is MINPOWER2? */ return block; /* do not need to reallocate */ else /* it crossed a power-of-2 boundary; grow to next power */ return luaM_realloc(L, block, luaO_power2(newn)*size); }
Hash *luaH_new (lua_State *L, int size) { Hash *t = luaM_new(L, Hash); t->htag = TagDefault; t->next = L->roottable; L->roottable = t; t->mark = t; t->size = 0; L->nblocks += gcsize(L, 0); t->node = NULL; setnodevector(L, t, luaO_power2(size)); return t; }