External strings

Strings can use external buffers to store their contents.
This commit is contained in:
Roberto Ierusalimschy
2023-11-09 17:05:42 -03:00
parent 7f4906f565
commit 024f9064f1
9 changed files with 195 additions and 14 deletions

4
lgc.c
View File

@@ -813,7 +813,9 @@ static void freeobj (lua_State *L, GCObject *o) {
}
case LUA_VLNGSTR: {
TString *ts = gco2ts(o);
luaM_freemem(L, ts, sizestrlng(ts->u.lnglen));
if (ts->shrlen == LSTRMEM) /* must free external string? */
(*ts->falloc)(ts->ud, ts->contents, ts->u.lnglen + 1, 0);
luaM_freemem(L, ts, luaS_sizelngstr(ts->u.lnglen, ts->shrlen));
break;
}
default: lua_assert(0);