[前][次][番号順一覧][スレッド一覧]

ruby-changes:18649

From: kosaki <ko1@a...>
Date: Thu, 27 Jan 2011 21:58:50 +0900 (JST)
Subject: [ruby-changes:18649] Ruby:r30673 (trunk): * bignum.c (rb_str_to_inum): get rid of too huge alloca().

kosaki	2011-01-27 21:58:44 +0900 (Thu, 27 Jan 2011)

  New Revision: 30673

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30673

  Log:
    * bignum.c (rb_str_to_inum): get rid of too huge alloca().

  Modified files:
    trunk/ChangeLog
    trunk/bignum.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 30672)
+++ ChangeLog	(revision 30673)
@@ -1,3 +1,7 @@
+Thu Jan 27 21:58:32 2011  KOSAKI Motohiro  <kosaki.motohiro@g...>
+
+	* bignum.c (rb_str_to_inum): get rid of too huge alloca().
+
 Thu Jan 27 21:43:29 2011  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* object.c (rb_str_to_dbl): rewrite again. use ALLOCV instead
Index: bignum.c
===================================================================
--- bignum.c	(revision 30672)
+++ bignum.c	(revision 30673)
@@ -734,6 +734,8 @@
 {
     char *s;
     long len;
+    VALUE v = 0;
+    VALUE ret;
 
     StringValue(str);
     if (badcheck) {
@@ -745,14 +747,17 @@
     if (s) {
 	len = RSTRING_LEN(str);
 	if (s[len]) {		/* no sentinel somehow */
-	    char *p = ALLOCA_N(char, len+1);
+	    char *p = ALLOCV(v, len+1);
 
 	    MEMCPY(p, s, char, len);
 	    p[len] = '\0';
 	    s = p;
 	}
     }
-    return rb_cstr_to_inum(s, base, badcheck);
+    ret = rb_cstr_to_inum(s, base, badcheck);
+    if (v)
+	ALLOCV_END(v);
+    return ret;
 }
 
 #if HAVE_LONG_LONG

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]