MCPcopy Create free account
hub / github.com/PlutoLang/Pluto / luaS_init

Function luaS_init

src/lstring.cpp:134–147  ·  view source on GitHub ↗

** Initialize the string table and the string cache */

Source from the content-addressed store, hash-verified

132** Initialize the string table and the string cache
133*/
134void luaS_init (lua_State *L) {
135 global_State *g = G(L);
136 int i, j;
137 stringtable *tb = &G(L)->strt;
138 tb->hash = luaM_newvector(L, MINSTRTABSIZE, TString*);
139 tablerehash(tb->hash, 0, MINSTRTABSIZE); /* clear array */
140 tb->size = MINSTRTABSIZE;
141 /* pre-create memory-error message */
142 g->memerrmsg = luaS_newliteral(L, MEMERRMSG);
143 luaC_fix(L, obj2gco(g->memerrmsg)); /* it should never be collected */
144 for (i = 0; i < STRCACHE_N; i++) /* fill cache with valid strings */
145 for (j = 0; j < STRCACHE_M; j++)
146 g->strcache[i][j] = g->memerrmsg;
147}
148
149
150size_t luaS_sizelngstr (size_t len, int kind) {

Callers 1

f_luaopenFunction · 0.85

Calls 2

tablerehashFunction · 0.85
luaC_fixFunction · 0.85

Tested by

no test coverage detected