[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Can heavy userdata move? (5alpha)
- From: "Adam D. Moss" <adam@...>
- Date: Tue, 26 Nov 2002 19:16:36 +0000
Hi!
I was wondering... once a heavy user data is created with
lua_newuserdata(), is it guaranteed to stay at that same returned
address until it is finally destroyed? For all I know,
the GC system moves objects around to help stop lua's
heap fragmenting, if not now then in a future version of the
garbage collector, but I don't want my heavy userdata moved.
I'm using tables of heavy-to-light userdata mappings to help
various parts of my project to pass (finalizable) hunks up through
a C API and back again; the 'light' userdata is just the raw
pointer that lua_newuserdata() returns, then these both get
put into the tables so I can map from one to the other (lua
uses the heavy versions but they need to be passed through the
C API and back again in their 'light' forms). But if heavy
userdata can move at some point so that lua_touserdata() differs
between the heavy and the light versions, I lose.
On a related point, if heavy userdata cannot move then it would be
VERY handy if heavy and light userdata hashed the same way from
within lua. Since AFAIK there's no way to distinguish between the
two types anyway from within lua (even typeof() prints exactly the
same) I think it's a fairly reasonable thing to ask or expect (and
the lack of this behaviour and its difficult debuggability caused
me a lot of confusion in the past).
Thanks,
--Adam
--
Adam D. Moss . ,,^^ adam@gimp.org http://www.foxbox.org/ co:3