[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Best way to save/re-load an lua state
- From: David Given <dg@...>
- Date: Sat, 21 Mar 2009 15:26:52 +0000
-----BEGIN PGP SIGNED MESSAGE-----
> If I would overwrite it in a way so that all memory used by my
> lua_State* is inside my own (pre-allocated) buffer, I could just save
> and re-load that buffer to/from disc and resume execution. What do you
> think, will this work? It sounds pretty easy so far.
This will only work if you new buffer is loaded at the same address as
the old one, as there'll be pointers embedded all throughout the data.
And if there happen to be pointers anywhere else --- such as on the
stack --- then you will be in for what is technically known as A World
Of Pain! Personally I'd go for something like Pluto, which
saves/restores the state at a much higher level.
> 2. What are the first two lines for?
> They do absolutely nothing, right? Are they there to let the compiler
> check something?
They're to avoid 'unused parameter' warnings.
┌─── ｄｇ＠ｃｏｗｌａｒｋ．ｃｏｍ ───── http://www.cowlark.com ─────
│ "All power corrupts, but we need electricity." --- Diana Wynne Jones,
│ _Archer's Goon_
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----