lua-users home
lua-l archive

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




On Fri, Mar 27, 2020 at 4:50 PM Sean Conner <sean@conman.org> wrote:
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
You're a gentleman and a scholar. (I'm so bad at C. I still can't believe people let me use a compiler.)

Russ