We have implemented the "longjmp-Restore stack environment" in our code base. The procedure longjmpis called by a specific function error_exitthat can be called from anywhere.
Thus, it is possible that the longjmpsubroutine setjmpmay not be called during a call , and the buffer may have an invalid value, resulting in a failure.
Can I initialize the buffer before NULLor is there any check to check for an invalid or invalid value. One way is that I can set the flag variable whenever called setjmp, and I can check it. But this is just a hack.
void error_exit()
{
extern jmp_buf buf;
longjmp(buf, 1);
return 1;
}
Can I do something like this?
void error_exit()
{
extern jmp_buf buf;
if(buf)
longjmp(buf, 1);
return 1;
}
C/++, , setjmp longjmp ++ , , longjmp , ?