1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

memory_view.c: prevent "warning: instance variable __memory_view__ not initialized"

This commit is contained in:
Kenta Murata 2020-09-25 23:45:00 +09:00
parent abdd3c5616
commit 8119e5b0e6
No known key found for this signature in database
GPG key ID: CEFE8AFB6081B062

View file

@ -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))