I32 i, depth = 0, *origin;
I32 cur, last, step;
+ LEAVE;
+
+ if (level <= 0) {
+ SU_UD_HANDLER(ud)(aTHX_ ud);
+ goto done;
+ }
+
SU_D(PerlIO_printf(Perl_debug_log, "%p: ### init for level %d\n", ud, level));
for (i = 0; i < level; ++i) {
SU_UD_ORIGIN(ud) = origin;
SU_UD_DEPTH(ud) = depth;
+
+ SU_D(PerlIO_printf(Perl_debug_log, "%p: set original destructor at %d [%d]\n",
+ ud, PL_savestack_ix, depth));
+
+ SAVEDESTRUCTOR_X(su_pop, ud);
+
+done:
+ ENTER;
+
return depth;
}
SU_UD_ORIGIN(ud) = NULL;
SU_UD_HANDLER(ud) = su_reap;
ud->cb = newSVsv(hook);
- LEAVE;
- if (level) {
- I32 depth = su_init(level, ud, 3);
- SU_D(PerlIO_printf(Perl_debug_log, "%p: set original destructor at %d [%d]\n",
- ud, PL_savestack_ix, depth));
- SAVEDESTRUCTOR_X(su_pop, ud);
- } else
- su_reap(ud);
- ENTER;
+ su_init(level, ud, 3);
void
localize(SV *sv, SV *val, ...)
ud->sv = sv;
ud->val = newSVsv(val);
ud->elem = NULL;
- LEAVE;
- if (level) {
- I32 depth = su_init(level, ud, 3);
- SU_D(PerlIO_printf(Perl_debug_log, "%p: set original destructor at %d [%d]\n",
- ud, PL_savestack_ix, depth));
- SAVEDESTRUCTOR_X(su_pop, ud);
- } else
- su_localize(ud);
- ENTER;
+ su_init(level, ud, 3);
void
localize_elem(SV *sv, SV *elem, SV *val, ...)
ud->val = newSVsv(val);
SvREFCNT_inc(elem);
ud->elem = elem;
- LEAVE;
- if (level) {
- I32 depth = su_init(level, ud, 4);
- SU_D(PerlIO_printf(Perl_debug_log, "%p: set original destructor at %d [%d]\n",
- ud, PL_savestack_ix, depth));
- SAVEDESTRUCTOR_X(su_pop, ud);
- } else
- su_localize(ud);
- ENTER;
-
+ su_init(level, ud, 4);