summaryrefslogtreecommitdiff
path: root/cop.h
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>2000-06-02 18:22:06 +0000
committerGurusamy Sarathy <gsar@cpan.org>2000-06-02 18:22:06 +0000
commitf4dd75d9918abbf789a5eca453b89168cad18ff0 (patch)
treec0348eda98b997c301b76ab702c0c93d888d87f5 /cop.h
parent4ebbc97598d793d933009eab4334e3bc88b8de4e (diff)
downloadperl-f4dd75d9918abbf789a5eca453b89168cad18ff0.tar.gz
fix small eval"" memory leaks under USE_ITHREADS
p4raw-id: //depot/perl@6194
Diffstat (limited to 'cop.h')
-rw-r--r--cop.h17
1 files changed, 9 insertions, 8 deletions
diff --git a/cop.h b/cop.h
index 3b3c3edbdb..d6fdd23ab2 100644
--- a/cop.h
+++ b/cop.h
@@ -29,32 +29,33 @@ struct cop {
# define CopFILE(c) ((c)->cop_file)
# define CopFILEGV(c) (CopFILE(c) \
? gv_fetchfile(CopFILE(c)) : Nullgv)
-# define CopFILE_set(c,pv) ((c)->cop_file = savepv(pv)) /* XXX */
+# define CopFILE_set(c,pv) ((c)->cop_file = savepv(pv))
# define CopFILESV(c) (CopFILE(c) \
? GvSV(gv_fetchfile(CopFILE(c))) : Nullsv)
# define CopFILEAV(c) (CopFILE(c) \
? GvAV(gv_fetchfile(CopFILE(c))) : Nullav)
# define CopSTASHPV(c) ((c)->cop_stashpv)
-# define CopSTASHPV_set(c,pv) ((c)->cop_stashpv = savepv(pv)) /* XXX */
+# define CopSTASHPV_set(c,pv) ((c)->cop_stashpv = savepv(pv))
# define CopSTASH(c) (CopSTASHPV(c) \
? gv_stashpv(CopSTASHPV(c),GV_ADD) : Nullhv)
# define CopSTASH_set(c,hv) CopSTASHPV_set(c, HvNAME(hv))
-# define CopSTASH_eq(c,hv) (hv \
+# define CopSTASH_eq(c,hv) ((hv) \
&& (CopSTASHPV(c) == HvNAME(hv) \
|| (CopSTASHPV(c) && HvNAME(hv) \
&& strEQ(CopSTASHPV(c), HvNAME(hv)))))
#else
# define CopFILEGV(c) ((c)->cop_filegv)
-# define CopFILEGV_set(c,gv) ((c)->cop_filegv = gv)
-# define CopFILE_set(c,pv) ((c)->cop_filegv = gv_fetchfile(pv))
+# define CopFILEGV_set(c,gv) ((c)->cop_filegv = (GV*)SvREFCNT_inc(gv))
+# define CopFILE_set(c,pv) CopFILEGV_set((c), gv_fetchfile(pv))
# define CopFILESV(c) (CopFILEGV(c) ? GvSV(CopFILEGV(c)) : Nullsv)
# define CopFILEAV(c) (CopFILEGV(c) ? GvAV(CopFILEGV(c)) : Nullav)
# define CopFILE(c) (CopFILESV(c) ? SvPVX(CopFILESV(c)) : Nullch)
# define CopSTASH(c) ((c)->cop_stash)
-# define CopSTASH_set(c,hv) ((c)->cop_stash = hv)
+# define CopSTASH_set(c,hv) ((c)->cop_stash = (hv))
# define CopSTASHPV(c) (CopSTASH(c) ? HvNAME(CopSTASH(c)) : Nullch)
-# define CopSTASHPV_set(c,pv) CopSTASH_set(c, gv_stashpv(pv,GV_ADD))
-# define CopSTASH_eq(c,hv) (CopSTASH(c) == hv)
+ /* cop_stash is not refcounted */
+# define CopSTASHPV_set(c,pv) CopSTASH_set((c), gv_stashpv(pv,GV_ADD))
+# define CopSTASH_eq(c,hv) (CopSTASH(c) == (hv))
#endif /* USE_ITHREADS */
#define CopSTASH_ne(c,hv) (!CopSTASH_eq(c,hv))