summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-27 12:46:30 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-27 12:46:30 +0000
commitac0178910ec628875dc81ee41f18b3a1757b18a8 (patch)
tree4eb14132cc7024b2393ff504fe8a2673c9cdf6ff
parent8d397b77ead6baeaab1b5da45c83a3a2fb1043e4 (diff)
* object.c (rb_str_to_dbl): rewrite again. use ALLOCV instead
rb_str_tmp_new(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--object.c11
2 files changed, 9 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 26dfaf76b1..591d373215 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Jan 27 21:43:29 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
+
+ * 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@gmail.com>
* win32/win32.c: get rid of STRNDUPA(). It's dangerous API.
diff --git a/object.c b/object.c
index 32777720ae..b25c0af1c2 100644
--- a/object.c
+++ b/object.c
@@ -2246,7 +2246,7 @@ rb_str_to_dbl(VALUE str, int badcheck)
char *s;
long len;
double ret;
- VALUE tmp = Qnil;
+ VALUE v = 0;
StringValue(str);
s = RSTRING_PTR(str);
@@ -2256,18 +2256,15 @@ rb_str_to_dbl(VALUE str, int badcheck)
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;
}