[GRASS-dev] Vect_*_fatal_error()

Martin Landa landa.martin at gmail.com
Thu Nov 17 08:51:51 EST 2011


Hi,

2011/11/14 Glynn Clements <glynn at gclements.plus.com>:
> Except .. that's going to need some support, as you can't use setjmp()
> directly from Python (the jmp_buf becomes invalid once you return from
> the function which "called" setjmp()). We would need something like:
>
>        static jmp_buf jbuf;
>
>        static void the_handler(void *unused)
>        {
>            longjmp(jbuf, 1);
>        }
>
>        void *G_safe_execute(void *(*func)(void *), void *closure)
>        {
>            G_add_error_handler(the_handler, NULL);
>            if (setjmp(jbuf) == 0) {
>                G_remove_error_handler(the_handler, NULL);
>                return (*func)(closure);
>            }
>            else {
>                G_remove_error_handler(the_handler, NULL);
>                return NULL;
>            }
>        }

this could be useful addition to gislib library. +1 to add
G-safe_execute() to gislib.

Thanks, Martin

-- 
Martin Landa <landa.martin gmail.com> * http://geo.fsv.cvut.cz/~landa


More information about the grass-dev mailing list