lua-users home
lua-l archive

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


On 25 March 2011 03:48, Jerome Vuarand <jerome.vuarand@gmail.com> wrote:
>  nargs = lua_gettop(L);
>  argv = (const char**)lua_newuserdata(L, nargs * sizeof(const char*));
>  argvlen = (size_t*)lua_newuserdata(L, nargs * sizeof(size_t));
>  for (i=0; i<nargs; ++i)
>  {
>    argv[i] = luaL_checklstring(L, i + 1, &argvlen[i]);
>  }
>

Is there something wrong with
        int params = lua_gettop(L);
        char **argv = malloc(params);
        int i;
        for (i=1;i<=params;i++) {
                argv[i-1]=luaL_checkstring(L,i);
        }


Daurnimator.