summaryrefslogtreecommitdiff
path: root/iseq.h
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-09 05:42:06 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-09 05:42:06 +0000
commit75d5cf55dea0c1351ebd37d432545935698c5c18 (patch)
tree4b16acf01b6079779eb98fe73eefb586437e0bcf /iseq.h
parent433a4e66a25c3c05c23565c45b6764d3f367fff4 (diff)
RSTRING_PTR is not guaranteed to be VALUE-aligned (retry)
Don't abuse struct RString to hold arbitrary memory region. Raw pointer should just suffice. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63368 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'iseq.h')
-rw-r--r--iseq.h15
1 files changed, 8 insertions, 7 deletions
diff --git a/iseq.h b/iseq.h
index de8beff..6789635 100644
--- a/iseq.h
+++ b/iseq.h
@@ -46,23 +46,24 @@ ISEQ_FLIP_CNT_INCREMENT(const rb_iseq_t *iseq)
static inline VALUE *
ISEQ_ORIGINAL_ISEQ(const rb_iseq_t *iseq)
{
- VALUE str = iseq->body->variable.original_iseq;
- if (RTEST(str)) return (VALUE *)RSTRING_PTR(str);
- return NULL;
+ return iseq->body->variable.original_iseq;
}
static inline void
ISEQ_ORIGINAL_ISEQ_CLEAR(const rb_iseq_t *iseq)
{
- RB_OBJ_WRITE(iseq, &iseq->body->variable.original_iseq, Qnil);
+ void *ptr = iseq->body->variable.original_iseq;
+ iseq->body->variable.original_iseq = NULL;
+ if (ptr) {
+ ruby_xfree(ptr);
+ }
}
static inline VALUE *
ISEQ_ORIGINAL_ISEQ_ALLOC(const rb_iseq_t *iseq, long size)
{
- VALUE str = rb_str_tmp_new(size * sizeof(VALUE));
- RB_OBJ_WRITE(iseq, &iseq->body->variable.original_iseq, str);
- return (VALUE *)RSTRING_PTR(str);
+ return iseq->body->variable.original_iseq =
+ ruby_xmalloc2(sizeof(VALUE), size);
}
#define ISEQ_TRACE_EVENTS (RUBY_EVENT_LINE | \