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

ruby-changes:18648

From: kosaki <ko1@a...>
Date: Thu, 27 Jan 2011 21:49:50 +0900 (JST)
Subject: [ruby-changes:18648] Ruby:r30672 (trunk): * object.c (rb_str_to_dbl): rewrite again. use ALLOCV instead

kosaki	2011-01-27 21:46:30 +0900 (Thu, 27 Jan 2011)

  New Revision: 30672

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

  Log:
    * object.c (rb_str_to_dbl): rewrite again. use ALLOCV instead
      rb_str_tmp_new().

  Modified files:
    trunk/ChangeLog
    trunk/object.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 30671)
+++ ChangeLog	(revision 30672)
@@ -1,3 +1,8 @@
+Thu Jan 27 21:43:29 2011  KOSAKI Motohiro  <kosaki.motohiro@g...>
+
+	* object.c (rb_str_to_dbl): rewrite again. use ALLOCV instead
+	  rb_str_tmp_new().
+
 Thu Jan 27 21:41:47 2011  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* win32/win32.c: get rid of STRNDUPA(). It's dangerous API.
Index: object.c
===================================================================
--- object.c	(revision 30671)
+++ object.c	(revision 30672)
@@ -2246,7 +2246,7 @@
     char *s;
     long len;
     double ret;
-    VALUE tmp = Qnil;
+    VALUE v = 0;
 
     StringValue(str);
     s = RSTRING_PTR(str);
@@ -2256,18 +2256,15 @@
 	    rb_raise(rb_eArgError, "string for Float contains null byte");
 	}
 	if (s[len]) {		/* no sentinel somehow */
-	    char *p;
-
-	    tmp = rb_str_tmp_new(len);
-	    p = RSTRING_PTR(tmp);
+	    char *p =  ALLOCV(v, len);
 	    MEMCPY(p, s, char, len);
 	    p[len] = '\0';
 	    s = p;
 	}
     }
     ret = rb_cstr_to_dbl(s, badcheck);
-    if (tmp != Qnil)
-	rb_str_resize(tmp, 0);
+    if (v)
+	ALLOCV_END(v);
     return ret;
 }
 

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

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