[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: luaL_buffinit stack manipulation
- From: Benoit Germain <bnt.germain@...>
- Date: Thu, 8 Jul 2021 12:09:00 +0200
Ok right. I have to do the whole dump mechanism Lua 5.4- style. Thanks for your help.
> when prepbuffsize is called, because my stack contains the function
> being dumped at the top (since that's what lua_dump needs), and
> prepbufsize does:
So you are violating:
You can use the stack between successive calls to buffer operations as
long as that use is balanced
from https://www.lua.org/manual/5.4/manual.html#luaL_Buffer since you
push the function after a buffer operation without removing it before
the next buffer operation in the write function.
You could argue that the design of either buffer or dump should be
changed. Buffers could include the stack slot they occupy since now they
allway occuply exactly one or dump could get a index to the function
instead of requireing in on the top.
It is also interesting so see how lua solved this issue for string.dump