Vaclav Barta <[EMAIL PROTECTED]> writes:
>On Monday 01 May 2006 10:34, Nick Ing-Simmons wrote:
>> > the second one croaks, it doesn't get a chance to release the first... Is
>> > there some equivalent of try/catch in XS, or a way to register the
>> > compiled regexp as a Perl object, to be released automatically when not
>> > needed?
>> try/catch (i.e. eval {} in perl speak) is a little tricky to do from pure
>> XS. I usually call (a trivial) perl sub and use G_EVAL on the call.
>> So Nick C's suggestion (to another question) of using SAVEDESTRUCTOR_X
>> is probably the easiest.
>>
>> ENTER;
>> SAVEDESTRUCTOR_X(your_cleanup_func, pointer_to_thing);
>> ...
>> risky_stuff();
>> LEAVE
>Yes, that's it - thanks. I suppose there's no harm in using just 
>SAVEDESTRUCTOR - I don't need the "context" to call pregfree (I 
>think :-) )...

What I would do in such a case is use pointer_to_thing to the 
struct regexp * to be free-d.

>
>       Bye
>               Vasek

Reply via email to