[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: C API question - modifing table
- From: Michael Roth <mroth@...>
- Date: Wed, 11 Aug 2004 14:58:20 +0200
Dmitry Samersoff wrote:
Now it works.
No, your code is wrong. You messed up with the index to the copy of the
key and value.
After lua_next() your stack looks:
table key value *
The index of the key is -2, and the index of the value is -1.
After lua_pushvalue(L, -2) your stack looks:
table key value copy_of_key *
You should work with the copy of the key. Its index is -1. Value's index
is -2.
After lua_pop(L, 2) your stack looks:
table key *
Got it?
Attachment:
signature.asc
Description: OpenPGP digital signature