summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--process.c17
2 files changed, 15 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index c318104e06..3cd9df7b90 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Wed Aug 21 21:02:37 2013 Tanaka Akira <akr@fsij.org>
+
+ * process.c (rb_proc_times): Use RB_GC_GUARD to guard objects from GC.
+
Wed Aug 21 20:33:01 2013 Tanaka Akira <akr@fsij.org>
* process.c (get_clk_tck): Extracted from rb_proc_times.
diff --git a/process.c b/process.c
index 8c6935a0b4..1fb9c15fdd 100644
--- a/process.c
+++ b/process.c
@@ -6641,14 +6641,19 @@ rb_proc_times(VALUE obj)
{
const double hertz = get_clk_tck();
struct tms buf;
- volatile VALUE utime, stime, cutime, sctime;
+ VALUE utime, stime, cutime, cstime, ret;
times(&buf);
- return rb_struct_new(rb_cProcessTms,
- utime = DBL2NUM(buf.tms_utime / hertz),
- stime = DBL2NUM(buf.tms_stime / hertz),
- cutime = DBL2NUM(buf.tms_cutime / hertz),
- sctime = DBL2NUM(buf.tms_cstime / hertz));
+ utime = DBL2NUM(buf.tms_utime / hertz);
+ stime = DBL2NUM(buf.tms_stime / hertz);
+ cutime = DBL2NUM(buf.tms_cutime / hertz);
+ cstime = DBL2NUM(buf.tms_cstime / hertz);
+ ret = rb_struct_new(rb_cProcessTms, utime, stime, cutime, cstime);
+ RB_GC_GUARD(utime);
+ RB_GC_GUARD(stime);
+ RB_GC_GUARD(cutime);
+ RB_GC_GUARD(cstime);
+ return ret;
}
#else
#define rb_proc_times rb_f_notimplement