OSDN Git Service

zdd overflow対策 master mining_1.3
authornain <nain0606@gmail.com>
Fri, 6 Dec 2013 05:20:13 +0000 (14:20 +0900)
committernain <nain0606@gmail.com>
Fri, 6 Dec 2013 05:20:13 +0000 (14:20 +0900)
Makefile
revison_hash
zdd/lib/gensrc.rb
zdd/lib/zdd_so.cxx

index be05f21..775a658 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 
-version = 1.2
+version = 1.3
 
 # 共有ライブラリの拡張子を自動設定
 ifeq ($(shell uname),Linux)
index 1e04e75..3fce83a 100644 (file)
@@ -1 +1 @@
-commit 8c34166f0be1d754582695083d96f774921f4ff7
+commit 6d4b686a97d30fcbe0c92d73169f45ad1e21f409
index 3743653..1c58218 100755 (executable)
@@ -534,8 +534,25 @@ func['| u_expr TOTALVAL'] =<<'SCP_EOF'
 VALUE vsop_totalval(VALUE self){
        Vsop_Ruby* rmod;
        Data_Get_Struct(self,Vsop_Ruby,rmod);
-  int val = rmod->cmod->TotalVal().GetInt();
-       return INT2NUM(val);
+
+       CtoI a = rmod->cmod->TotalVal();        
+       if(a.IsConst())
+       {       
+               if(a.TopItem() > 0) a = a.MaxVal();
+               int d = a.TopDigit() / 3 + 14;
+               kgAutoPtr2<char> a_ptr;
+               char *s;
+               try{
+                       a_ptr.set(new char[d]);
+                       s = a_ptr.get();
+               }catch(...){
+                       rb_raise(rb_eRuntimeError,\"memory allocation error\");
+               }
+         int err = a.StrNum10(s);
+         if (err) { rb_raise(rb_eRuntimeError,\"StrNum10 error\"); }
+               return rb_cstr2inum(s,10);
+       }
+       return 0;
 }
 "
 SCP_EOF
index f1fa795..47a7868 100644 (file)
@@ -1601,9 +1601,22 @@ VALUE vsop_const_to_i(VALUE self){
        Vsop_Ruby* rmod;
        Data_Get_Struct(self,Vsop_Ruby,rmod);
 
-       if(rmod->cmod->IsConst()){
-               int val = rmod->cmod->GetInt();
-               return INT2NUM(val);
+       CtoI a = *(rmod->cmod);
+       
+       if(a.IsConst()){
+               if(a.TopItem() > 0) a = a.MaxVal();
+               int d = a.TopDigit() / 3 + 14;
+               kgAutoPtr2<char> a_ptr;
+               char *s;
+               try{
+                       a_ptr.set(new char[d]);
+                       s = a_ptr.get();
+               }catch(...){
+                       rb_raise(rb_eRuntimeError,"memory allocation error");
+               }
+         int err = a.StrNum10(s);
+         if (err) { rb_raise(rb_eRuntimeError,"StrNum10 error"); }
+               return rb_cstr2inum(s,10);
        }else{
                return Qnil;
        }