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