[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Is there something like a lua_trypushstring() with return value? Could there be?
- From: Roberto Ierusalimschy <roberto@...>
- Date: Fri, 12 Nov 2021 11:19:54 -0300
> 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:
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