MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / luaS_newextlstr

Function luaS_newextlstr

third-party/lua-5.5.0/src/lstring.c:318–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

316
317
318TString *luaS_newextlstr (lua_State *L,
319 const char *s, size_t len, lua_Alloc falloc, void *ud) {
320 struct NewExt ne;
321 if (!falloc) {
322 ne.kind = LSTRFIX;
323 f_newext(L, &ne); /* just create header */
324 }
325 else {
326 ne.kind = LSTRMEM;
327 if (luaD_rawrunprotected(L, f_newext, &ne) != LUA_OK) { /* mem. error? */
328 (*falloc)(ud, cast_voidp(s), len + 1, 0); /* free external string */
329 luaM_error(L); /* re-raise memory error */
330 }
331 ne.ts->falloc = falloc;
332 ne.ts->ud = ud;
333 }
334 ne.ts->shrlen = ne.kind;
335 ne.ts->u.lnglen = len;
336 ne.ts->contents = cast_charp(s);
337 return ne.ts;
338}
339
340
341/*

Callers 2

loadStringFunction · 0.85
lua_pushexternalstringFunction · 0.85

Calls 2

f_newextFunction · 0.85
luaD_rawrunprotectedFunction · 0.70

Tested by

no test coverage detected