develooper Front page | perl.perl5.porters | Postings from March 2001

Re: my purify runs with 5.6.1-to-be

Thread Previous | Thread Next
From:
Gurusamy Sarathy
Date:
March 16, 2001 13:25
Subject:
Re: my purify runs with 5.6.1-to-be
Message ID:
200103162125.f2GLP5517786@smtp3.ActiveState.com
On Fri, 16 Mar 2001 13:15:30 PST, Gurusamy Sarathy wrote:
>I think you may be on the right track here.  I'd probably change
>the patch to refcount PmopSTASH() instead.

Here is a modified version that does that (untested).


Sarathy
gsar@ActiveState.com
-----------------------------------8<-----------------------------------
Index: perl/op.c
--- perl/op.c.~1~	Sun Mar  4 22:30:19 2001
+++ perl/op.c	Sun Mar  4 22:30:19 2001
@@ -842,6 +842,29 @@
     case OP_MATCH:
     case OP_QR:
 clear_pmop:
+	{
+	    HV *pmstash = PmopSTASH(cPMOPo);
+	    if (pmstash) {
+		PMOP *pmop = HvPMROOT(pmstash);
+		PMOP *lastpmop = NULL;
+		while (pmop) {
+		    if (cPMOPo == pmop) {
+			if (lastpmop)
+			    lastpmop->op_pmnext = pmop->op_pmnext;
+			else
+			    HvPMROOT(pmstash) = pmop->op_pmnext;
+			break;
+		    }
+		    lastpmop = pmop;
+		    pmop = pmop->op_pmnext;
+		}
+#ifdef USE_ITHREADS
+		Safefree(PmopSTASHPV(cPMOPo));
+#else
+		SvREFCNT_dec(pmstash);
+#endif
+	    }
+	}
 	cPMOPo->op_pmreplroot = Nullop;
 	ReREFCNT_dec(cPMOPo->op_pmregexp);
 	cPMOPo->op_pmregexp = (REGEXP*)NULL;
@@ -2914,6 +2937,7 @@
     if (type != OP_TRANS && PL_curstash) {
 	pmop->op_pmnext = HvPMROOT(PL_curstash);
 	HvPMROOT(PL_curstash) = pmop;
+	PmopSTASH_set(pmop,PL_curstash);
     }
 
     return (OP*)pmop;
Index: perl/op.h
--- perl/op.h.~1~	Sun Mar  4 22:30:19 2001
+++ perl/op.h	Sun Mar  4 22:30:19 2001
@@ -242,6 +242,11 @@
     U16		op_pmflags;
     U16		op_pmpermflags;
     U8		op_pmdynflags;
+#ifdef USE_ITHREADS
+    char *	op_pmstashpv;
+#else
+    HV *	op_pmstash;
+#endif
 };
 
 #define PMdf_USED	0x01		/* pm has been used once already */
@@ -267,6 +272,19 @@
 
 /* mask of bits stored in regexp->reganch */
 #define PMf_COMPILETIME	(PMf_MULTILINE|PMf_SINGLELINE|PMf_LOCALE|PMf_FOLD|PMf_EXTENDED)
+
+#ifdef USE_ITHREADS
+#  define PmopSTASHPV(o)	((o)->op_pmstashpv)
+#  define PmopSTASHPV_set(o,pv)	((o)->op_pmstashpv = ((pv) ? savepv(pv) : Nullch))
+#  define PmopSTASH(o)		(PmopSTASHPV(o) \
+				 ? gv_stashpv(PmopSTASHPV(o),GV_ADD) : Nullhv)
+#  define PmopSTASH_set(o,hv)	PmopSTASHPV_set(o, (hv) ? HvNAME(hv) : Nullch)
+#else
+#  define PmopSTASH(o)		((o)->op_pmstash)
+#  define PmopSTASH_set(o,hv)	((o)->op_pmstash = (hv))
+#  define PmopSTASHPV(o)	(PmopSTASH(o) ? HvNAME(PmopSTASH(o)) : Nullch)
+#  define PmopSTASHPV_set(o,pv)	PmopSTASH_set((o), SvREFCNT_inc(gv_stashpv(pv,GV_ADD)))
+#endif
 
 struct svop {
     BASEOP
End of Patch.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About