diff options
author | Kenta Murata <mrkn@mrkn.jp> | 2020-09-25 23:45:00 +0900 |
---|---|---|
committer | Kenta Murata <mrkn@mrkn.jp> | 2020-09-25 23:56:38 +0900 |
commit | 8119e5b0e6a1341a9130c14604ade5acca6d21f3 (patch) | |
tree | 53a260fd697b6f376d4a91806f89d97511d99347 /memory_view.c | |
parent | abdd3c5616e82af487249ef5e9d3e42bc983de1c (diff) | |
download | ruby-8119e5b0e6a1341a9130c14604ade5acca6d21f3.tar.gz |
memory_view.c: prevent "warning: instance variable __memory_view__ not initialized"
Diffstat (limited to 'memory_view.c')
-rw-r--r-- | memory_view.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/memory_view.c b/memory_view.c index e45cbeb796..6d75b9de1b 100644 --- a/memory_view.c +++ b/memory_view.c @@ -7,6 +7,7 @@ **********************************************************************/ #include "internal.h" +#include "internal/variable.h" #include "internal/util.h" #include "ruby/memory_view.h" @@ -31,7 +32,7 @@ static const rb_data_type_t memory_view_entry_data_type = { bool rb_memory_view_register(VALUE klass, const rb_memory_view_entry_t *entry) { Check_Type(klass, T_CLASS); - VALUE entry_obj = rb_ivar_get(klass, id_memory_view); + VALUE entry_obj = rb_ivar_lookup(klass, id_memory_view, Qnil); if (! NIL_P(entry_obj)) { rb_warning("Duplicated registration of memory view to %"PRIsVALUE, klass); return 0; @@ -447,14 +448,14 @@ rb_memory_view_get_item_pointer(rb_memory_view_t *view, const ssize_t *indices) static const rb_memory_view_entry_t * lookup_memory_view_entry(VALUE klass) { - VALUE entry_obj = rb_ivar_get(klass, id_memory_view); + VALUE entry_obj = rb_ivar_lookup(klass, id_memory_view, Qnil); while (NIL_P(entry_obj)) { klass = rb_class_get_superclass(klass); if (klass == rb_cBasicObject || klass == rb_cObject) return NULL; - entry_obj = rb_ivar_get(klass, id_memory_view); + entry_obj = rb_ivar_lookup(klass, id_memory_view, Qnil); } if (! rb_typeddata_is_kind_of(entry_obj, &memory_view_entry_data_type)) |