summaryrefslogtreecommitdiff
path: root/iseq.h
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-09 02:36:34 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-09 02:36:34 +0000
commit7079db9ec5acef3321e92c32d7ef086d8d16d720 (patch)
treee077a699dc51b89c0dd95d871998f032bbe49ad6 /iseq.h
parent6061071f4060cf83e877ea9090d1b5a4f09b2856 (diff)
RSTRING_PTR is not guaranteed to be VALUE-aligned
Don't abuse struct RString to hold arbitrary memory region. use rb_alloc_tmp_buffer for that purpose. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63362 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'iseq.h')
-rw-r--r--iseq.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/iseq.h b/iseq.h
index de8beff..aad9bdd 100644
--- a/iseq.h
+++ b/iseq.h
@@ -46,23 +46,25 @@ 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);
+ rb_imemo_alloc_t *str = (void *)iseq->body->variable.original_iseq;
+ if (RTEST(str)) return str->ptr;
return NULL;
}
static inline void
ISEQ_ORIGINAL_ISEQ_CLEAR(const rb_iseq_t *iseq)
{
- RB_OBJ_WRITE(iseq, &iseq->body->variable.original_iseq, Qnil);
+ rb_free_tmp_buffer(&iseq->body->variable.original_iseq);
+ RB_OBJ_WRITE(iseq, &iseq->body->variable.original_iseq, Qfalse);
}
static inline VALUE *
ISEQ_ORIGINAL_ISEQ_ALLOC(const rb_iseq_t *iseq, long size)
{
- VALUE str = rb_str_tmp_new(size * sizeof(VALUE));
+ VALUE str;
+ VALUE *ptr = rb_alloc_tmp_buffer_with_count(&str, sizeof(VALUE), size);
RB_OBJ_WRITE(iseq, &iseq->body->variable.original_iseq, str);
- return (VALUE *)RSTRING_PTR(str);
+ return ptr;
}
#define ISEQ_TRACE_EVENTS (RUBY_EVENT_LINE | \