Projects

Ticket #573: void size bug.diff

File void size bug.diff, 2.7 KB (added by danielcavanagh@…, 6 months ago)
  • bridgesupport.cpp

     
    572572        bool raise_exception_if_unknown); 
    573573 
    574574VALUE 
    575 rb_pointer_new(const char *type_str, void *val, size_t len) 
     575rb_pointer_new(const char *type_str, size_t len, void *val) 
    576576{ 
    577577    // LLVM doesn't allow to get a pointer to Type::VoidTy, and for convenience 
    578578    // reasons we map a pointer to void as a pointer to unsigned char. 
     
    594594    assert(ptr->type_size > 0); 
    595595    ptr->len = len; 
    596596 
     597    if (val == NULL) 
     598        val = xmalloc(ptr->type_size * len); 
    597599    GC_WB(&ptr->val, val); 
    598600 
    599601    return Data_Wrap_Struct(rb_cPointer, NULL, NULL, ptr); 
     
    613615                    "can't convert an empty array to a `%s' pointer", 
    614616                    type_str); 
    615617        } 
    616         p = rb_pointer_new(type_str, 
    617                 xmalloc(GET_CORE()->get_sizeof(type_str) * len), len); 
     618        p = rb_pointer_new(type_str, len, NULL); 
    618619        for (int i = 0; i < len; i++) { 
    619620            rb_pointer_aset(p, 0, INT2FIX(i), RARRAY_AT(rval, i)); 
    620621        } 
    621622    } 
    622623    else { 
    623         p = rb_pointer_new(type_str, 
    624                 xmalloc(GET_CORE()->get_sizeof(type_str)), 1); 
     624        p = rb_pointer_new(type_str, 1, NULL); 
    625625        rb_pointer_aset(p, 0, INT2FIX(0), rval); 
    626626    } 
    627627 
     
    646646 
    647647    const char *type_str = convert_ffi_type(type, false); 
    648648 
    649     return rb_pointer_new(type_str, 
    650             xmalloc(GET_CORE()->get_sizeof(type_str) * rlen), rlen); 
     649    return rb_pointer_new(type_str, rlen, NULL); 
    651650} 
    652651 
    653652void * 
  • compiler.cpp

     
    65266526VALUE 
    65276527rb_vm_new_pointer(const char *type, void *val) 
    65286528{ 
    6529     return val == NULL ? Qnil : rb_pointer_new(type, val, 0); 
     6529    return val == NULL ? Qnil : rb_pointer_new(type, 0, val); 
    65306530} 
    65316531 
    65326532Value * 
  • vm.cpp

     
    727727size_t 
    728728RoxorCore::get_sizeof(const Type *type) 
    729729{ 
    730     return ee->getTargetData()->getTypeSizeInBits(type) / 8; 
     730    return type->isSized() ? ee->getTargetData()->getTypeSizeInBits(type) / 8 : 0; 
    731731} 
    732732 
    733733size_t 
  • bridgesupport.h

     
    2525    VALUE klass; 
    2626} rb_vm_bs_boxed_t; 
    2727 
    28 VALUE rb_pointer_new(const char *type_str, void *val, size_t len); 
     28VALUE rb_pointer_new(const char *type_str, size_t len, void *val); 
    2929VALUE rb_pointer_new2(const char *type_str, VALUE val); 
    3030void *rb_pointer_get_data(VALUE rcv, const char *type); 
    3131