summaryrefslogtreecommitdiff
path: root/scope.c
diff options
context:
space:
mode:
authorMalcolm Beattie <mbeattie@sable.ox.ac.uk>1998-03-16 16:22:58 +0000
committerMalcolm Beattie <mbeattie@sable.ox.ac.uk>1998-03-16 16:22:58 +0000
commitbb13cb927b2b56cd314cd059be1c58034bedcc3b (patch)
treef3f389b2b11d7d56beb3557664f728d7f5d8dcac /scope.c
parent5476c4332a5540db7fc38bfabed95022b6c04b1b (diff)
parentb7afe3d5943df4dc5b5a482d4e543e4c94d92333 (diff)
downloadperl-bb13cb927b2b56cd314cd059be1c58034bedcc3b.tar.gz
Bump patchlevel.h to 63.
p4raw-id: //depot/perl@822
Diffstat (limited to 'scope.c')
-rw-r--r--scope.c92
1 files changed, 60 insertions, 32 deletions
diff --git a/scope.c b/scope.c
index 6de1841eb5..f1a0b6ff09 100644
--- a/scope.c
+++ b/scope.c
@@ -167,11 +167,12 @@ SV *
save_scalar(GV *gv)
{
dTHR;
+ SV **sptr = &GvSV(gv);
SSCHECK(3);
- SSPUSHPTR(gv);
- SSPUSHPTR(GvSV(gv));
+ SSPUSHPTR(SvREFCNT_inc(gv));
+ SSPUSHPTR(SvREFCNT_inc(*sptr));
SSPUSHINT(SAVEt_SV);
- return save_scalar_at(&GvSV(gv));
+ return save_scalar_at(sptr);
}
SV*
@@ -180,7 +181,7 @@ save_svref(SV **sptr)
dTHR;
SSCHECK(3);
SSPUSHPTR(sptr);
- SSPUSHPTR(*sptr);
+ SSPUSHPTR(SvREFCNT_inc(*sptr));
SSPUSHINT(SAVEt_SVREF);
return save_scalar_at(sptr);
}
@@ -440,35 +441,11 @@ save_delete(HV *hv, char *key, I32 klen)
SSCHECK(4);
SSPUSHINT(klen);
SSPUSHPTR(key);
- SSPUSHPTR(hv);
+ SSPUSHPTR(SvREFCNT_inc(hv));
SSPUSHINT(SAVEt_DELETE);
}
void
-save_aelem(AV *av, I32 idx, SV **sptr)
-{
- dTHR;
- SSCHECK(4);
- SSPUSHPTR(av);
- SSPUSHINT(idx);
- SSPUSHPTR(*sptr);
- SSPUSHINT(SAVEt_AELEM);
- save_scalar_at(sptr);
-}
-
-void
-save_helem(HV *hv, SV *key, SV **sptr)
-{
- dTHR;
- SSCHECK(4);
- SSPUSHPTR(hv);
- SSPUSHPTR(key);
- SSPUSHPTR(*sptr);
- SSPUSHINT(SAVEt_HELEM);
- save_scalar_at(sptr);
-}
-
-void
save_list(register SV **sarg, I32 maxsarg)
{
dTHR;
@@ -496,6 +473,30 @@ save_destructor(void (*f) (void *), void *p)
}
void
+save_aelem(AV *av, I32 idx, SV **sptr)
+{
+ dTHR;
+ SSCHECK(4);
+ SSPUSHPTR(SvREFCNT_inc(av));
+ SSPUSHINT(idx);
+ SSPUSHPTR(SvREFCNT_inc(*sptr));
+ SSPUSHINT(SAVEt_AELEM);
+ save_scalar_at(sptr);
+}
+
+void
+save_helem(HV *hv, SV *key, SV **sptr)
+{
+ dTHR;
+ SSCHECK(4);
+ SSPUSHPTR(SvREFCNT_inc(hv));
+ SSPUSHPTR(SvREFCNT_inc(key));
+ SSPUSHPTR(SvREFCNT_inc(*sptr));
+ SSPUSHINT(SAVEt_HELEM);
+ save_scalar_at(sptr);
+}
+
+void
save_op(void)
{
dTHR;
@@ -532,6 +533,7 @@ leave_scope(I32 base)
value = (SV*)SSPOPPTR;
gv = (GV*)SSPOPPTR;
ptr = &GvSV(gv);
+ SvREFCNT_dec(gv);
goto restore_sv;
case SAVEt_SVREF: /* scalar reference */
value = (SV*)SSPOPPTR;
@@ -563,6 +565,7 @@ leave_scope(I32 base)
localizing = 2;
SvSETMAGIC(value);
localizing = 0;
+ SvREFCNT_dec(value);
break;
case SAVEt_AV: /* array reference */
av = (AV*)SSPOPPTR;
@@ -719,6 +722,7 @@ leave_scope(I32 base)
hv = (HV*)ptr;
ptr = SSPOPPTR;
(void)hv_delete(hv, (char*)ptr, (U32)SSPOPINT, G_DISCARD);
+ SvREFCNT_dec(hv);
Safefree(ptr);
break;
case SAVEt_DESTRUCTOR:
@@ -738,14 +742,38 @@ leave_scope(I32 base)
i = SSPOPINT;
av = (AV*)SSPOPPTR;
ptr = av_fetch(av,i,1);
- goto restore_sv;
+ if (ptr) {
+ sv = *(SV**)ptr;
+ if (sv && sv != &sv_undef) {
+ if (SvRMAGICAL(av) && mg_find((SV*)av, 'P'))
+ (void)SvREFCNT_inc(sv);
+ SvREFCNT_dec(av);
+ goto restore_sv;
+ }
+ }
+ SvREFCNT_dec(av);
+ SvREFCNT_dec(value);
+ break;
case SAVEt_HELEM: /* hash element */
value = (SV*)SSPOPPTR;
sv = (SV*)SSPOPPTR;
hv = (HV*)SSPOPPTR;
ptr = hv_fetch_ent(hv, sv, 1, 0);
- ptr = &HeVAL((HE*)ptr);
- goto restore_sv;
+ if (ptr) {
+ SV *oval = HeVAL((HE*)ptr);
+ if (oval && oval != &sv_undef) {
+ ptr = &HeVAL((HE*)ptr);
+ if (SvRMAGICAL(hv) && mg_find((SV*)hv, 'P'))
+ (void)SvREFCNT_inc(*(SV**)ptr);
+ SvREFCNT_dec(hv);
+ SvREFCNT_dec(sv);
+ goto restore_sv;
+ }
+ }
+ SvREFCNT_dec(hv);
+ SvREFCNT_dec(sv);
+ SvREFCNT_dec(value);
+ break;
case SAVEt_OP:
op = (OP*)SSPOPPTR;
break;