summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2006-12-17 17:17:34 -0500
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-12-18 16:06:38 +0000
commit6a3d5e3dbfbb290a39e3787450653a41f07f3b5d (patch)
tree919cbe41888dfb8fb191c942adddf029b56ae7a7
parentc38a65302a7e2e2ea9b8748d368c87d573add6fd (diff)
downloadperl-6a3d5e3dbfbb290a39e3787450653a41f07f3b5d.tar.gz
Re: [PATCH] do not meddle in the affairs of PERL_TRACK_MEMPOOL
Message-ID: <4586084E.8040706@iki.fi> Introduce CopLABEL() macro to deal with labels attached to COPs. p4raw-id: //depot/perl@29585
-rw-r--r--cop.h11
-rw-r--r--op.c16
-rw-r--r--scope.h4
3 files changed, 17 insertions, 14 deletions
diff --git a/cop.h b/cop.h
index d75d2f1194..722e135e4b 100644
--- a/cop.h
+++ b/cop.h
@@ -186,12 +186,20 @@ struct cop {
? gv_stashpv(CopSTASHPV(c),GV_ADD) : NULL)
# define CopSTASH_set(c,hv) CopSTASHPV_set(c, (hv) ? HvNAME_get(hv) : NULL)
# define CopSTASH_eq(c,hv) ((hv) && stashpv_hvname_match(c,hv))
+# define CopLABEL(c) ((c)->cop_label)
+# ifdef NETWARE
+# define CopLABEL_set(c,pv) ((CopLABEL(c) = ((pv) ? savepv(pv) : NULL)), Safefree(pv), ((pv) = NULL))
+# else
+# define CopLABEL_set(c,pv) ((CopLABEL(c) = savesharedpv(pv)), Safefree(pv), ((pv) = NULL))
+# endif
# ifdef NETWARE
# define CopSTASH_free(c) SAVECOPSTASH_FREE(c)
# define CopFILE_free(c) SAVECOPFILE_FREE(c)
+# define CopLABEL_free(c) SAVECOPLABEL_FREE(c)
# else
# define CopSTASH_free(c) PerlMemShared_free(CopSTASHPV(c))
# define CopFILE_free(c) (PerlMemShared_free(CopFILE(c)),(CopFILE(c) = NULL))
+# define CopLABEL_free(c) (PerlMemShared_free(CopLABEL(c)),(CopLABEL(c) = NULL))
# endif
#else
# define CopFILEGV(c) ((c)->cop_filegv)
@@ -206,13 +214,16 @@ struct cop {
# endif
# define CopFILE(c) (CopFILESV(c) ? SvPVX(CopFILESV(c)) : NULL)
# define CopSTASH(c) ((c)->cop_stash)
+# define CopLABEL(c) ((c)->cop_label)
# define CopSTASH_set(c,hv) ((c)->cop_stash = (hv))
# define CopSTASHPV(c) (CopSTASH(c) ? HvNAME_get(CopSTASH(c)) : NULL)
/* 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))
+# define CopLABEL_set(c,pv) (CopLABEL(c) = (pv))
# define CopSTASH_free(c)
# define CopFILE_free(c) (SvREFCNT_dec(CopFILEGV(c)),(CopFILEGV(c) = NULL))
+# define CopLABEL_free(c)
#endif /* USE_ITHREADS */
diff --git a/op.c b/op.c
index 2ed219811e..2c10b2b5a3 100644
--- a/op.c
+++ b/op.c
@@ -514,19 +514,7 @@ clear_pmop:
STATIC void
S_cop_free(pTHX_ COP* cop)
{
- if (cop->cop_label) {
-#ifdef PERL_TRACK_MEMPOOL
- Malloc_t ptr = (Malloc_t)(cop->cop_label - sTHX);
- struct perl_memory_debug_header *const header
- = (struct perl_memory_debug_header *)ptr;
- /* Only the thread that allocated us can free us. */
- if (header->interpreter == aTHX)
-#endif
- {
- Safefree(cop->cop_label);
- cop->cop_label = NULL;
- }
- }
+ CopLABEL_free(cop);
CopFILE_free(cop);
CopSTASH_free(cop);
if (! specialWARN(cop->cop_warnings))
@@ -4004,7 +3992,7 @@ Perl_newSTATEOP(pTHX_ I32 flags, char *label, OP *o)
cop->op_next = (OP*)cop;
if (label) {
- cop->cop_label = label;
+ CopLABEL_set(cop, label);
PL_hints |= HINT_BLOCK_SCOPE;
}
cop->cop_seq = seq;
diff --git a/scope.h b/scope.h
index 377a8b42fe..c80430066f 100644
--- a/scope.h
+++ b/scope.h
@@ -219,11 +219,15 @@ Closing bracket on a callback. See C<ENTER> and L<perlcall>.
# define SAVECOPSTASH_FREE(c) SAVESHAREDPV(CopSTASHPV(c))
# define SAVECOPFILE(c) SAVEPPTR(CopFILE(c))
# define SAVECOPFILE_FREE(c) SAVESHAREDPV(CopFILE(c))
+# define SAVECOPLABEL(c) SAVEPPTR(CopLABEL(c))
+# define SAVECOPLABEL_FREE(c) SAVESHAREDPV(CopLABEL(c))
#else
# define SAVECOPSTASH(c) SAVESPTR(CopSTASH(c))
# define SAVECOPSTASH_FREE(c) SAVECOPSTASH(c) /* XXX not refcounted */
# define SAVECOPFILE(c) SAVESPTR(CopFILEGV(c))
# define SAVECOPFILE_FREE(c) SAVEGENERICSV(CopFILEGV(c))
+# define SAVECOPLABEL(c) SAVEPPTR(CopLABEL(c))
+# define SAVECOPLABEL_FREE(c) SAVEPPTR(CopLABEL(c))
#endif
#define SAVECOPLINE(c) SAVEI32(CopLINE(c))