lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Currently the address will not change, since the GC is non-compacting.
I'm not sure whether the authors plan to maintain this as an
invariant.


On Wed, 16 Mar 2005 18:02:01 +0000, Warren Merrifield
<wmerrifield@gmail.com> wrote:
> I think I already know the answer to this, but I'm not sure, so i
> thought I would check:
> 
> I create some full userdata, using the C API, and get a pointer to a
> block of memory back. I create a reference to this userdata so that it
> won't get garbage collected until I want it to. Will the address of my
> memory remain constant throughout the lifetime of the userdata (i.e.
> outside the scope of the function which created it)
> 
> I want to be able to do something like
> 
>        d0 = AddDisplayObject(def)
>        d1 = AddDisplayObject(def)
>        rungame()
> 
> in Lua, and then get the addresses for the userdata display objects
> every frame in C without having to call back into Lua every time.
> 
> Thanks for any help,
> Warren
>