[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: String parameters when calling C from Lua
- From: "Daniel Collins" <daniel.collins@...>
- Date: Fri, 19 May 2006 19:51:37 +0930
> > When calling a C function from lua with a string argument, is that
> > string copied onto the stack that the C function gets? Or does the
> > stack contain a pointer to the original string?
> Neither. The stack contains a Lua value, which can be
> converted to a C string (const char*) with lua_tostring. The
> pointer returned by lua_tostring points to the internal copy
> of the string inside Lua. --lhf
Let me ask a different question:
Out of the two implementations I sketched out, would there be any
significant performance difference between them? Basically I am
interested in the relative efficiency of passing strings vs numbers from
lua to C.
>From what you say I suspect that there is no real difference. Which
means I should go with the solution that will be easiest to maintain.