diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1998-03-09 03:51:01 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1998-03-09 03:51:01 +0000 |
commit | 4e4c362ec2e3f4b5f5c23aa83a26a13b85d0c2c1 (patch) | |
tree | a06b5a015a32d7281f7b1e82ee2ed810c0af86ae /scope.c | |
parent | 9404a519907ec8d9bce4b0bf7a09103f1f9f6fcb (diff) | |
download | perl-4e4c362ec2e3f4b5f5c23aa83a26a13b85d0c2c1.tar.gz |
[win32] merge C<local $tied{foo}> patch, also moved statics in
[ah]v.c to thrdvar.h
p4raw-id: //depot/win32/perl@802
Diffstat (limited to 'scope.c')
-rw-r--r-- | scope.c | 92 |
1 files changed, 60 insertions, 32 deletions
@@ -155,11 +155,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* @@ -168,7 +169,7 @@ save_svref(SV **sptr) dTHR; SSCHECK(3); SSPUSHPTR(sptr); - SSPUSHPTR(*sptr); + SSPUSHPTR(SvREFCNT_inc(*sptr)); SSPUSHINT(SAVEt_SVREF); return save_scalar_at(sptr); } @@ -428,35 +429,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; @@ -484,6 +461,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; @@ -520,6 +521,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; @@ -551,6 +553,7 @@ leave_scope(I32 base) localizing = 2; SvSETMAGIC(value); localizing = 0; + SvREFCNT_dec(value); break; case SAVEt_AV: /* array reference */ av = (AV*)SSPOPPTR; @@ -707,6 +710,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: @@ -726,14 +730,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; |