Ticket #573: void size bug.diff
| File void size bug.diff, 2.7 KB (added by danielcavanagh@…, 6 months ago) |
|---|
-
bridgesupport.cpp
572 572 bool raise_exception_if_unknown); 573 573 574 574 VALUE 575 rb_pointer_new(const char *type_str, void *val, size_t len)575 rb_pointer_new(const char *type_str, size_t len, void *val) 576 576 { 577 577 // LLVM doesn't allow to get a pointer to Type::VoidTy, and for convenience 578 578 // reasons we map a pointer to void as a pointer to unsigned char. … … 594 594 assert(ptr->type_size > 0); 595 595 ptr->len = len; 596 596 597 if (val == NULL) 598 val = xmalloc(ptr->type_size * len); 597 599 GC_WB(&ptr->val, val); 598 600 599 601 return Data_Wrap_Struct(rb_cPointer, NULL, NULL, ptr); … … 613 615 "can't convert an empty array to a `%s' pointer", 614 616 type_str); 615 617 } 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); 618 619 for (int i = 0; i < len; i++) { 619 620 rb_pointer_aset(p, 0, INT2FIX(i), RARRAY_AT(rval, i)); 620 621 } 621 622 } 622 623 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); 625 625 rb_pointer_aset(p, 0, INT2FIX(0), rval); 626 626 } 627 627 … … 646 646 647 647 const char *type_str = convert_ffi_type(type, false); 648 648 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); 651 650 } 652 651 653 652 void * -
compiler.cpp
6526 6526 VALUE 6527 6527 rb_vm_new_pointer(const char *type, void *val) 6528 6528 { 6529 return val == NULL ? Qnil : rb_pointer_new(type, val, 0);6529 return val == NULL ? Qnil : rb_pointer_new(type, 0, val); 6530 6530 } 6531 6531 6532 6532 Value * -
vm.cpp
727 727 size_t 728 728 RoxorCore::get_sizeof(const Type *type) 729 729 { 730 return ee->getTargetData()->getTypeSizeInBits(type) / 8;730 return type->isSized() ? ee->getTargetData()->getTypeSizeInBits(type) / 8 : 0; 731 731 } 732 732 733 733 size_t -
bridgesupport.h
25 25 VALUE klass; 26 26 } rb_vm_bs_boxed_t; 27 27 28 VALUE rb_pointer_new(const char *type_str, void *val, size_t len);28 VALUE rb_pointer_new(const char *type_str, size_t len, void *val); 29 29 VALUE rb_pointer_new2(const char *type_str, VALUE val); 30 30 void *rb_pointer_get_data(VALUE rcv, const char *type); 31 31

