#define CvXSUBANY(sv) ((XPVCV*)SvANY(sv))->xcv_xsubany
#define CvGV(sv) ((XPVCV*)SvANY(sv))->xcv_gv
#define CvFILE(sv) ((XPVCV*)SvANY(sv))->xcv_file
+#ifdef USE_ITHREADS
+# define CvFILE_set_from_cop(sv, cop) (CvFILE(sv) = savepv(CopFILE(cop)))
+#else
+# define CvFILE_set_from_cop(sv, cop) (CvFILE(sv) = CopFILE(cop))
+#endif
#define CvFILEGV(sv) (gv_fetchfile(CvFILE(sv))
#define CvDEPTH(sv) ((XPVCV*)SvANY(sv))->xcv_depth
#define CvPADLIST(sv) ((XPVCV*)SvANY(sv))->xcv_padlist
}
#endif /* USE_THREADS */
+#ifdef USE_ITHREADS
+ if (CvFILE(cv) && !CvXSUB(cv)) {
+ Safefree(CvFILE(cv));
+ CvFILE(cv) = 0;
+ }
+#endif
+
if (!CvXSUB(cv) && CvROOT(cv)) {
#ifdef USE_THREADS
if (CvDEPTH(cv) || (CvOWNER(cv) && CvOWNER(cv) != thr))
MUTEX_INIT(CvMUTEXP(cv));
CvOWNER(cv) = 0;
#endif /* USE_THREADS */
+#ifdef USE_ITHREADS
+ CvFILE(cv) = CvXSUB(proto) ? CvFILE(proto)
+ : savepv(CvFILE(proto));
+#else
CvFILE(cv) = CvFILE(proto);
+#endif
CvGV(cv) = CvGV(proto);
CvSTASH(cv) = CvSTASH(proto);
CvROOT(cv) = OpREFCNT_inc(CvROOT(proto));
}
}
CvGV(cv) = gv;
- CvFILE(cv) = CopFILE(PL_curcop);
+ CvFILE_set_from_cop(cv, PL_curcop);
CvSTASH(cv) = PL_curstash;
#ifdef USE_THREADS
CvOWNER(cv) = 0;
cv = PL_compcv;
GvFORM(gv) = cv;
CvGV(cv) = gv;
- CvFILE(cv) = CopFILE(PL_curcop);
+ CvFILE_set_from_cop(cv, PL_curcop);
for (ix = AvFILLp(PL_comppad); ix > 0; ix--) {
if (!SvPADMY(PL_curpad[ix]) && !SvIMMORTAL(PL_curpad[ix]))