| 48 | |
| 49 | |
| 50 | static TString *newlstr (lua_State *L, const char *str, size_t l, |
| 51 | unsigned int h) { |
| 52 | TString *ts; |
| 53 | stringtable *tb; |
| 54 | if (l+1 > (MAX_SIZET - sizeof(TString))/sizeof(char)) |
| 55 | luaM_toobig(L); |
| 56 | ts = cast(TString *, luaM_malloc(L, (l+1)*sizeof(char)+sizeof(TString))); |
| 57 | ts->tsv.len = l; |
| 58 | ts->tsv.hash = h; |
| 59 | ts->tsv.marked = luaC_white(G(L)); |
| 60 | ts->tsv.tt = LUA_TSTRING; |
| 61 | ts->tsv.reserved = 0; |
| 62 | memcpy(ts+1, str, l*sizeof(char)); |
| 63 | ((char *)(ts+1))[l] = '\0'; /* ending 0 */ |
| 64 | tb = &G(L)->strt; |
| 65 | h = lmod(h, tb->size); |
| 66 | ts->tsv.next = tb->hash[h]; /* chain new entry */ |
| 67 | tb->hash[h] = obj2gco(ts); |
| 68 | tb->nuse++; |
| 69 | if (tb->nuse > cast(lu_int32, tb->size) && tb->size <= MAX_INT/2) |
| 70 | luaS_resize(L, tb->size*2); /* too crowded */ |
| 71 | return ts; |
| 72 | } |
| 73 | |
| 74 | |
| 75 | TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { |
no test coverage detected