From 4eda1acafa1a69224b2d4f786cf1ec8f7a4d9ac5 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 14 Dec 2023 11:41:57 -0300 Subject: Cleaner protocol between 'lua_dump' and writer function 'lua_dump' signals to the writer function the end of a dump, so that is has more freedom when using the stack. --- lundump.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lundump.c') diff --git a/lundump.c b/lundump.c index 3f18343a..f850dc4a 100644 --- a/lundump.c +++ b/lundump.c @@ -152,7 +152,7 @@ static void loadString (LoadState *S, Proto *p, TString **sl) { luaH_getint(S->h, idx, &stv); *sl = ts = tsvalue(&stv); luaC_objbarrier(L, p, ts); - return; + return; /* do not save it again */ } else if ((size -= 2) <= LUAI_MAXSHORTLEN) { /* short string? */ char buff[LUAI_MAXSHORTLEN + 1]; /* extra space for '\0' */ @@ -168,10 +168,10 @@ static void loadString (LoadState *S, Proto *p, TString **sl) { else { /* create internal copy */ *sl = ts = luaS_createlngstrobj(L, size); /* create string */ luaC_objbarrier(L, p, ts); - loadVector(S, getlngstr(ts), size); /* load directly in final place */ - loadByte(S); /* skip ending '\0' */ + loadVector(S, getlngstr(ts), size + 1); /* load directly in final place */ } - S->nstr++; /* add string to list of saved strings */ + /* add string to list of saved strings */ + S->nstr++; setsvalue(L, &sv, ts); luaH_setint(L, S->h, S->nstr, &sv); luaC_objbarrierback(L, obj2gco(S->h), ts); -- cgit v1.2.3-55-g6feb