** new string (with explicit length) */
| 231 | ** new string (with explicit length) |
| 232 | */ |
| 233 | TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { |
| 234 | if (l <= LUAI_MAXSHORTLEN) /* short string? */ |
| 235 | return internshrstr(L, str, l); |
| 236 | else { |
| 237 | TString *ts; |
| 238 | if (unlikely(l >= (MAX_SIZE - sizeof(TString))/sizeof(char))) |
| 239 | luaM_toobig(L); |
| 240 | ts = luaS_createlngstrobj(L, l); |
| 241 | memcpy(getstr(ts), str, l * sizeof(char)); |
| 242 | return ts; |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | |
| 247 | /* |
no test coverage detected