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