lua-users home
lua-l archive

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


On Jul 26, 2002 at 02:34 +0200, Benoit Germain wrote:
> this forces an allocation for the duplication of the string inside the lua
> state, that will be discarded from the stack as soon as the purpose of its
> presence is fulfilled: it adds an extra load on the garbage collector.
> maybe simply exposing a function n=lua_stringtonumber(s) could do the trick,
> and if one wants to put the value on the stack, just call
> lua_pushnumber(L,lua_stringtonumber(s)) ?

lua_pushnumber(L, atoi(s));

Or have I misunderstood the problem...

> > From: Roberto Ierusalimschy [mailto:roberto@inf.puc-rio.br]
> > 
> > What about this?
> >   lua_pushstring(L, s);
> >   n = lua_tonumber(L, -1);
> > 
> > -- Roberto
> > 

-- 
Thatcher Ulrich
http://tulrich.com