MCPcopy Create free account
hub / github.com/BigPig0/RelayLive / luaS_resize

Function luaS_resize

ThirdParty/lua/lua/lstring.c:60–85  ·  view source on GitHub ↗

** resizes the string table */

Source from the content-addressed store, hash-verified

58** resizes the string table
59*/
60void luaS_resize (lua_State *L, int newsize) {
61 int i;
62 stringtable *tb = &G(L)->strt;
63 if (newsize > tb->size) { /* grow table if needed */
64 luaM_reallocvector(L, tb->hash, tb->size, newsize, TString *);
65 for (i = tb->size; i < newsize; i++)
66 tb->hash[i] = NULL;
67 }
68 for (i = 0; i < tb->size; i++) { /* rehash */
69 TString *p = tb->hash[i];
70 tb->hash[i] = NULL;
71 while (p) { /* for each node in the list */
72 TString *hnext = p->hnext; /* save next */
73 unsigned int h = lmod(p->hash, newsize); /* new position */
74 p->hnext = tb->hash[h]; /* chain it */
75 tb->hash[h] = p;
76 p = hnext;
77 }
78 }
79 if (newsize < tb->size) { /* shrink table if needed */
80 /* vanishing slice should be empty */
81 lua_assert(tb->hash[newsize] == NULL && tb->hash[tb->size - 1] == NULL);
82 luaM_reallocvector(L, tb->hash, tb->size, newsize, TString *);
83 }
84 tb->size = newsize;
85}
86
87
88

Callers 3

f_luaopenFunction · 0.85
internshrstrFunction · 0.85
checkSizesFunction · 0.85

Calls 1

GFunction · 0.50

Tested by

no test coverage detected