** new string (with explicit length) */
| 220 | ** new string (with explicit length) |
| 221 | */ |
| 222 | TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { |
| 223 | if (l <= LUAI_MAXSHORTLEN) /* short string? */ |
| 224 | return internshrstr(L, str, l); |
| 225 | else { |
| 226 | TString *ts; |
| 227 | if (l_unlikely(l * sizeof(char) >= (MAX_SIZE - sizeof(TString)))) |
| 228 | luaM_toobig(L); |
| 229 | ts = luaS_createlngstrobj(L, l); |
| 230 | memcpy(getlngstr(ts), str, l * sizeof(char)); |
| 231 | return ts; |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | |
| 236 | /* |
no test coverage detected