lua-users home
lua-l archive

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


> I'm wondering though, couldn't the lua_pushcfunction itself cause an out of
> memory error too? My apologies if I'm reading it wrong, but to me it seems
> like it moves the problem around with the same outcome - that the
> "ppushstring" might OOM setjmp like "lua_pushstring", without allowing me a
> more controlled recovery to clean things up.

No, lua_pushcfunction (as opposed to lua_pushcclosure with a non-zero n)
cannot raise a memory error. See the manual:

    lua_pushcclosure
    
    void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n);
    [...]
     When n is zero, this function creates a light C function, which is
     just a pointer to the C function. In that case, it never raises a
     memory error.

-- Roberto