lua-users home
lua-l archive

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

On Friday 01 October 2004 00:18, Antero Vipunen wrote:
>   Is the using of longjump always correct?
>   For example consider the following samples:

Looks fine to me. Remember that lua_error() calls longjmp() and longjmp() 
never returns.

>       testi(error(L));

testi() never gets called here.

>   Is it correct? Can this code somehow corrupt the stack?

longjmp() discards all the C stack back to where setjmp() was called. No 
cleanup is done, so any memory that was allocated and the sole pointer to 
which is stored on the stack will be leaked. There are some complex semantics 
as to what local variables you're allowed to use across a call to setjmp(), 
but that's not your problem... I don't think you have any issues here.

+- David Given --McQ-+ " could wire up a *dead rat* to a DIMM
|    | socket, and the PC BIOS memory test would pass it
| ( | just fine." --- Ethan Benson
+- --+