[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: UserData.
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 31 Jan 2001 09:42:09 -0200
> I'm having trouble assigning NULL values to userdata items...
This is a bug in Lua 4.0; it was already reported by ET:
> Message-ID: <3A40E68E.48EF1F9D@gmx.de>
> Date: Wed, 20 Dec 2000 18:04:14 +0100
> From: Edgar Toernig <firstname.lastname@example.org>
> PS: Btw, lua_newuserdata and co are IMHO slightly broken:
> > print(dostring"") -- gives lua_pusheruserdata(L, NULL)
> userdata(0): 0x80632b0
> > print(dostring"")
> userdata(0): 0x8063448 -- and another one?!?
> Maybe this change
> - ts->u.d.value = (udata == NULL) ? uts+1 : udata;
> + ts->u.d.value = s ? uts+1 : udata;
> would make a little bit more sense. (There are other
> problems too. Still thinking about a solution.)
(The change is in lstring.c:122)
I think his fix will solve the problem, although I don't know what
would be the "other problems". (lua_newuserdata will return NULL if you
ask for zero bytes, but that is OK.)