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