** new string (with explicit length) */
| 197 | ** new string (with explicit length) |
| 198 | */ |
| 199 | TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { |
| 200 | if (l <= LUAI_MAXSHORTLEN) /* short string? */ |
| 201 | return internshrstr(L, str, l); |
| 202 | else { |
| 203 | TString *ts; |
| 204 | if (l >= (MAX_SIZE - sizeof(TString))/sizeof(char)) |
| 205 | luaM_toobig(L); |
| 206 | ts = luaS_createlngstrobj(L, l); |
| 207 | memcpy(getstr(ts), str, l * sizeof(char)); |
| 208 | return ts; |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | |
| 213 | /* |
no test coverage detected