[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Passing vararg from C to Lua?
- From: Sean Conner <sean@...>
- Date: Fri, 27 Mar 2020 19:50:07 -0400
It was thus said that the Great Russell Haley once stated:
>
> Okay, this seems to work (in 1 out of 1 tested scenarios!):
>
> int wrlog(lua_Integer level, char * format, ...)
> {
> char buffer[LOG_STR_SZ];
> va_list args;
> va_start (args, format);
> vsnprintf (buffer,LOG_STR_SZ,format, args);
>
> lua_getglobal(L, "write_log");
> lua_pushinteger(L, level);
> lua_pushstring(L, (const char*)&buffer);
> // return (lua_pcall(L, 2, 0, (void*)NULL));
> lua_call(L, 2, 0);
> return (0);
> }
You are missing a call to va_end(). Even though the function may work
without it, it may be required by other systems. You can add it after the
vsnprintf() call.
-spc