** Initialize the string table and the string cache */
| 121 | ** Initialize the string table and the string cache |
| 122 | */ |
| 123 | void luaS_init (lua_State *L) { |
| 124 | global_State *g = G(L); |
| 125 | int i, j; |
| 126 | stringtable *tb = &G(L)->strt; |
| 127 | tb->hash = luaM_newvector(L, MINSTRTABSIZE, TString*); |
| 128 | tablerehash(tb->hash, 0, MINSTRTABSIZE); /* clear array */ |
| 129 | tb->size = MINSTRTABSIZE; |
| 130 | /* pre-create memory-error message */ |
| 131 | g->memerrmsg = luaS_newliteral(L, MEMERRMSG); |
| 132 | luaC_fix(L, obj2gco(g->memerrmsg)); /* it should never be collected */ |
| 133 | for (i = 0; i < STRCACHE_N; i++) /* fill cache with valid strings */ |
| 134 | for (j = 0; j < STRCACHE_M; j++) |
| 135 | g->strcache[i][j] = g->memerrmsg; |
| 136 | } |
| 137 | |
| 138 | |
| 139 |
no test coverage detected