summaryrefslogtreecommitdiff
path: root/op.h
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2008-01-08 17:10:29 +0000
committerNicholas Clark <nick@ccl4.org>2008-01-08 17:10:29 +0000
commit10599a699e18a26ba9c9154ce2c01e7cf53249ce (patch)
tree10bede87c74177d62b57585acf5c760f0469be98 /op.h
parent9a8b670905dec428f75660a49918537c7271b6b6 (diff)
downloadperl-10599a699e18a26ba9c9154ce2c01e7cf53249ce.tar.gz
In PL_regexp_padav, store regexps via real references, rather than
hiding them within IVs. We can do this now that they are real SV pointers. p4raw-id: //depot/perl@32900
Diffstat (limited to 'op.h')
-rw-r--r--op.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/op.h b/op.h
index adf5d1f223..2bb042bfa0 100644
--- a/op.h
+++ b/op.h
@@ -329,18 +329,26 @@ struct pmop {
};
#ifdef USE_ITHREADS
-#define PM_GETRE(o) (INT2PTR(REGEXP*,SvIVX(PL_regex_pad[(o)->op_pmoffset])))
+#define PM_GETRE(o) (SvROK(PL_regex_pad[(o)->op_pmoffset]) ? \
+ (REGEXP*)SvRV(PL_regex_pad[(o)->op_pmoffset]) : NULL)
/* The assignment is just to enforce type safety (or at least get a warning).
*/
#define PM_SETRE(o,r) STMT_START { \
const REGEXP *const slosh = (r); \
- PM_SETRE_OFFSET((o), PTR2IV(slosh)); \
+ SV *const whap = PL_regex_pad[(o)->op_pmoffset]; \
+ SvIOK_off(whap); \
+ SvROK_on(whap); \
+ SvRV_set(whap, (SV*)slosh); \
} STMT_END
/* Actually you can assign any IV, not just an offset. And really should it be
UV? */
+/* Need to turn the SvOK off as the regexp code is quite carefully manually
+ reference counting the thing pointed to, so don't want sv_setiv also
+ deciding to clear a reference count because it sees an SV. */
#define PM_SETRE_OFFSET(o,iv) \
STMT_START { \
SV* const sv = PL_regex_pad[(o)->op_pmoffset]; \
+ SvROK_off(sv); \
sv_setiv(sv, (iv)); \
} STMT_END