#define save_freeop Perl_save_freeop
#define save_freepv Perl_save_freepv
#define save_freesv Perl_save_freesv
+#define save_generic_svref Perl_save_generic_svref
#define save_gp Perl_save_gp
#define save_hash Perl_save_hash
#define save_helem Perl_save_helem
save_freeop
save_freepv
save_freesv
+save_generic_svref
save_gp
save_hash
save_helem
#define save_freeop pPerl->Perl_save_freeop
#undef save_freepv
#define save_freepv pPerl->Perl_save_freepv
+#undef save_generic_svref
+#define save_generic_svref pPerl->Perl_generic_save_svref
#undef save_gp
#define save_gp pPerl->Perl_save_gp
#undef save_hash
#define save_freeop CPerlObj::Perl_save_freeop
#undef save_freepv
#define save_freepv CPerlObj::Perl_save_freepv
+#undef save_generic_svref
+#define save_generic_svref CPerlObj::Perl_save_generic_svref
#undef save_gp
#define save_gp CPerlObj::Perl_save_gp
#undef save_hash
ENTER;
SAVETMPS;
lex_start(sv_2mortal(newSVpv("",0)));
- if (PL_rsfp_filters){
- save_aptr(&PL_rsfp_filters);
- PL_rsfp_filters = NULL;
- }
+ SAVEGENERICSV(PL_rsfp_filters);
+ PL_rsfp_filters = Nullav;
PL_rsfp = tryrsfp;
name = savepv(name);
VIRTUAL void save_freesv _((SV* sv));
VIRTUAL void save_freeop _((OP* o));
VIRTUAL void save_freepv _((char* pv));
+VIRTUAL void save_generic_svref _((SV** sptr));
VIRTUAL void save_gp _((GV* gv, I32 empty));
VIRTUAL HV* save_hash _((GV* gv));
VIRTUAL void save_helem _((HV* hv, SV *key, SV **sptr));
return save_scalar_at(sptr);
}
+/* Like save_svref(), but doesn't deal with magic. Can be used to
+ * restore a global SV to its prior contents, freeing new value. */
+void
+save_generic_svref(SV **sptr)
+{
+ dTHR;
+ SSCHECK(3);
+ SSPUSHPTR(sptr);
+ SSPUSHPTR(SvREFCNT_inc(*sptr));
+ SSPUSHINT(SAVEt_GENERIC_SVREF);
+}
+
void
save_gp(GV *gv, I32 empty)
{
ptr = &GvSV(gv);
SvREFCNT_dec(gv);
goto restore_sv;
+ case SAVEt_GENERIC_SVREF: /* generic sv */
+ value = (SV*)SSPOPPTR;
+ ptr = SSPOPPTR;
+ if (ptr) {
+ sv = *(SV**)ptr;
+ *(SV**)ptr = value;
+ SvREFCNT_dec(sv);
+ }
+ SvREFCNT_dec(value);
+ break;
case SAVEt_SVREF: /* scalar reference */
value = (SV*)SSPOPPTR;
ptr = SSPOPPTR;
-#define SAVEt_ITEM 0
-#define SAVEt_SV 1
-#define SAVEt_AV 2
-#define SAVEt_HV 3
-#define SAVEt_INT 4
-#define SAVEt_LONG 5
-#define SAVEt_I32 6
-#define SAVEt_IV 7
-#define SAVEt_SPTR 8
-#define SAVEt_APTR 9
-#define SAVEt_HPTR 10
-#define SAVEt_PPTR 11
-#define SAVEt_NSTAB 12
-#define SAVEt_SVREF 13
-#define SAVEt_GP 14
-#define SAVEt_FREESV 15
-#define SAVEt_FREEOP 16
-#define SAVEt_FREEPV 17
-#define SAVEt_CLEARSV 18
-#define SAVEt_DELETE 19
-#define SAVEt_DESTRUCTOR 20
-#define SAVEt_REGCONTEXT 21
-#define SAVEt_STACK_POS 22
-#define SAVEt_I16 23
-#define SAVEt_AELEM 24
-#define SAVEt_HELEM 25
-#define SAVEt_OP 26
-#define SAVEt_HINTS 27
-#define SAVEt_ALLOC 28
+#define SAVEt_ITEM 0
+#define SAVEt_SV 1
+#define SAVEt_AV 2
+#define SAVEt_HV 3
+#define SAVEt_INT 4
+#define SAVEt_LONG 5
+#define SAVEt_I32 6
+#define SAVEt_IV 7
+#define SAVEt_SPTR 8
+#define SAVEt_APTR 9
+#define SAVEt_HPTR 10
+#define SAVEt_PPTR 11
+#define SAVEt_NSTAB 12
+#define SAVEt_SVREF 13
+#define SAVEt_GP 14
+#define SAVEt_FREESV 15
+#define SAVEt_FREEOP 16
+#define SAVEt_FREEPV 17
+#define SAVEt_CLEARSV 18
+#define SAVEt_DELETE 19
+#define SAVEt_DESTRUCTOR 20
+#define SAVEt_REGCONTEXT 21
+#define SAVEt_STACK_POS 22
+#define SAVEt_I16 23
+#define SAVEt_AELEM 24
+#define SAVEt_HELEM 25
+#define SAVEt_OP 26
+#define SAVEt_HINTS 27
+#define SAVEt_ALLOC 28
+#define SAVEt_GENERIC_SVREF 29
#define SSCHECK(need) if (PL_savestack_ix + need > PL_savestack_max) savestack_grow()
#define SSPUSHINT(i) (PL_savestack[PL_savestack_ix++].any_i32 = (I32)(i))
#define LEAVE_SCOPE(old) if (PL_savestack_ix > old) leave_scope(old)
/*
- * Not using SOFT_CAST on SAVEFREESV and SAVEFREESV
+ * Not using SOFT_CAST on SAVESPTR, SAVEGENERICSV and SAVEFREESV
* because these are used for several kinds of pointer values
*/
#define SAVEI16(i) save_I16(SOFT_CAST(I16*)&(i))
#define SAVEFREEOP(o) save_freeop(SOFT_CAST(OP*)(o))
#define SAVEFREEPV(p) save_freepv(SOFT_CAST(char*)(p))
#define SAVECLEARSV(sv) save_clearsv(SOFT_CAST(SV**)&(sv))
+#define SAVEGENERICSV(s) save_generic_svref((SV**)&(s))
#define SAVEDELETE(h,k,l) \
save_delete(SOFT_CAST(HV*)(h), SOFT_CAST(char*)(k), (I32)(l))
#ifdef PERL_OBJECT