[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Garbage collector issues
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 20 Dec 2000 11:37:44 -0200
> One solution could be something like:
>
> LUA_API void lua_userdatasize(lua_State *L, size_t size)
>
> which would assign the given size in bytes (to the GC) to the userdata
> situated on top of the stack.
You can implement this function as follows (I gess ;-):
/* in lapi.c */
LUA_API void lua_userdatasize (lua_State *L, size_t size) {
if (ttype(L->top-1) != LUA_TUSERDATA ||
tsvalue(L->top-1)->len != 0)
lua_error("...");
tsvalue(L->top-1)->len = size;
L->nblocks += size*sizeof(char);
}
Maybe something similar should go into the official API for 4.1...
-- Roberto