** new string (with explicit length) */
| 247 | ** new string (with explicit length) |
| 248 | */ |
| 249 | TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { |
| 250 | if (l <= LUAI_MAXSHORTLEN) /* short string? */ |
| 251 | return internshrstr(L, str, l); |
| 252 | else { |
| 253 | TString *ts; |
| 254 | if (l_unlikely(l * sizeof(char) >= (MAX_SIZE - sizeof(TString)))) |
| 255 | luaM_toobig(L); |
| 256 | ts = luaS_createlngstrobj(L, l); |
| 257 | memcpy(getlngstr(ts), str, l * sizeof(char)); |
| 258 | return ts; |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | |
| 263 | /* |
no test coverage detected