Index: bridgesupport.cpp
===================================================================
--- bridgesupport.cpp	(revision 3328)
+++ bridgesupport.cpp	(working copy)
@@ -572,7 +572,7 @@
 	bool raise_exception_if_unknown);
 
 VALUE
-rb_pointer_new(const char *type_str, void *val, size_t len)
+rb_pointer_new(const char *type_str, size_t len, void *val)
 {
     // LLVM doesn't allow to get a pointer to Type::VoidTy, and for convenience
     // reasons we map a pointer to void as a pointer to unsigned char.
@@ -594,6 +594,8 @@
     assert(ptr->type_size > 0);
     ptr->len = len;
 
+    if (val == NULL)
+	val = xmalloc(ptr->type_size * len);
     GC_WB(&ptr->val, val);
 
     return Data_Wrap_Struct(rb_cPointer, NULL, NULL, ptr);
@@ -613,15 +615,13 @@
 		    "can't convert an empty array to a `%s' pointer",
 		    type_str);
 	}
-	p = rb_pointer_new(type_str,
-		xmalloc(GET_CORE()->get_sizeof(type_str) * len), len);
+	p = rb_pointer_new(type_str, len, NULL);
 	for (int i = 0; i < len; i++) {
 	    rb_pointer_aset(p, 0, INT2FIX(i), RARRAY_AT(rval, i));
 	}
     }
     else {
-	p = rb_pointer_new(type_str,
-		xmalloc(GET_CORE()->get_sizeof(type_str)), 1);
+	p = rb_pointer_new(type_str, 1, NULL);
 	rb_pointer_aset(p, 0, INT2FIX(0), rval);
     }
 
@@ -646,8 +646,7 @@
 
     const char *type_str = convert_ffi_type(type, false);
 
-    return rb_pointer_new(type_str,
-	    xmalloc(GET_CORE()->get_sizeof(type_str) * rlen), rlen);
+    return rb_pointer_new(type_str, rlen, NULL);
 }
 
 void *
Index: compiler.cpp
===================================================================
--- compiler.cpp	(revision 3328)
+++ compiler.cpp	(working copy)
@@ -6526,7 +6526,7 @@
 VALUE
 rb_vm_new_pointer(const char *type, void *val)
 {
-    return val == NULL ? Qnil : rb_pointer_new(type, val, 0);
+    return val == NULL ? Qnil : rb_pointer_new(type, 0, val);
 }
 
 Value *
Index: vm.cpp
===================================================================
--- vm.cpp	(revision 3328)
+++ vm.cpp	(working copy)
@@ -727,7 +727,7 @@
 size_t
 RoxorCore::get_sizeof(const Type *type)
 {
-    return ee->getTargetData()->getTypeSizeInBits(type) / 8;
+    return type->isSized() ? ee->getTargetData()->getTypeSizeInBits(type) / 8 : 0;
 }
 
 size_t
Index: bridgesupport.h
===================================================================
--- bridgesupport.h	(revision 3328)
+++ bridgesupport.h	(working copy)
@@ -25,7 +25,7 @@
     VALUE klass;
 } rb_vm_bs_boxed_t;
 
-VALUE rb_pointer_new(const char *type_str, void *val, size_t len);
+VALUE rb_pointer_new(const char *type_str, size_t len, void *val);
 VALUE rb_pointer_new2(const char *type_str, VALUE val);
 void *rb_pointer_get_data(VALUE rcv, const char *type);
 
