Watson1978
7/6/2011 - 4:50 PM

NArray : https://github.com/masa16/narray

diff --git a/Rakefile b/Rakefile
index 1e41707..f94998c 100644
--- a/Rakefile
+++ b/Rakefile
@@ -77,6 +77,8 @@ specification_version: 2
 summary: N-dimensional Numerical Array class for Ruby
 test_files: []
 
+licenses: []
+
 EOF
 
 Rake::GemPackageTask.new(spec) do |pkg|
diff --git a/narray.c b/narray.c
index f374d61..a0baf56 100644
--- a/narray.c
+++ b/narray.c
@@ -160,6 +160,7 @@ struct NARRAY*
 #define RCLASS_SUPER(v) (RCLASS(v)->super)
 #endif
 
+#if 0
 static void
  na_check_class_narray(VALUE v)
 {
@@ -173,7 +174,7 @@ static void
   }
   rb_raise(rb_eRuntimeError, "need NArray or its subclass");
 }
-
+#endif
 
 static VALUE
  na_wrap_struct_class(struct NARRAY *ary, VALUE klass)
@@ -189,7 +190,7 @@ static VALUE
   }
 
   /* check NArray >= klass */
-  na_check_class_narray(klass);
+  //na_check_class_narray(klass);
 
   /* Check dimension */
   class_dim = NUM2INT(rb_const_get(klass, na_id_class_dim));
diff --git a/narray.h b/narray.h
index d6523df..9522dde 100644
--- a/narray.h
+++ b/narray.h
@@ -26,6 +26,25 @@
 #define NARRAY_VERSION "0.5.9p9"
 #define NARRAY_VERSION_CODE 599
 
+#ifdef __MACRUBY__
+/* We cannot use the GC memory functions here because the underlying libedit
+ * function will call free() on the memory, resulting in a leak.
+ */
+# undef ALLOC
+# define ALLOC(type) (type*)malloc(sizeof(type))
+# undef ALLOC_N
+# define ALLOC_N(type,n) ((type *)malloc(sizeof(type) * (n)))
+# undef REALLOC_N
+# define REALLOC_N(var,type,n) \
+    (var)=(type*)realloc((char*)(var),(n) * sizeof(type))
+# define ruby_xfree(x) free(x)
+
+# undef xmalloc
+# define xmalloc(x) malloc(x)
+# undef xfree
+# define xfree(x) free(x)
+#endif
+
 /*
   Data types used in NArray :
   Please modify these types if your system has any different type.