lua-users home
lua-l archive

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



-----Message d'origine-----
De : D Burgess [mailto:david@spinifex.net]
Envoyé : lundi 17 février 2003 17:00
À : Multiple recipients of list
Objet : Re: Need for help...


> newuserdata() returns a void * pointer to a block of
> memory off the lua internal memory pool.

Lua creates not only that, but also all the necessary support to be
referenced as a value, the metatable mechanism, etc.

> Because it comes from the lua pool, lua will garbage
> collect the userdata when there are no more references
> to it.

This can be the case for external allocation as well if you use a boxpointer
(a full userdata that contains only a pointer to a block you allocate
elsewhere), with a __gc metamethod that frees the block when the userdata is
collected.


Cheers,


Benoit.