summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2012-10-28 22:47:08 -0700
committerYukihiro "Matz" Matsumoto <[email protected]>2012-10-28 22:47:08 -0700
commit4d1a8718bdaea6f2686a2f52795fb3e3794bf448 (patch)
tree0fc18daeddf8430dae241c82bc91f111b2cf3c14
parentcfc1269d334a04a5dfb8a9b397c5716fe2ccffc1 (diff)
parentf3090c3000a469475385f2bb861a6ad7e7f635ae (diff)
downloadmruby-4d1a8718bdaea6f2686a2f52795fb3e3794bf448.tar.gz
mruby-4d1a8718bdaea6f2686a2f52795fb3e3794bf448.zip
Merge pull request #513 from monaka/pr-not-use-memset-in-structure-initialization3
Use substitution instead of memset in structure initialization.
-rw-r--r--src/gc.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/gc.c b/src/gc.c
index 46699aea3..37e4a363b 100644
--- a/src/gc.c
+++ b/src/gc.c
@@ -326,6 +326,7 @@ struct RBasic*
mrb_obj_alloc(mrb_state *mrb, enum mrb_vtype ttype, struct RClass *cls)
{
struct RBasic *p;
+ static const RVALUE RVALUE_zero = { { { 0 } } };
#ifdef MRB_GC_STRESS
mrb_garbage_collect(mrb);
@@ -345,7 +346,7 @@ mrb_obj_alloc(mrb_state *mrb, enum mrb_vtype ttype, struct RClass *cls)
mrb->live++;
gc_protect(mrb, p);
- memset(p, 0, sizeof(RVALUE));
+ *(RVALUE *)p = RVALUE_zero;
p->tt = ttype;
p->c = cls;
paint_partial_white(mrb, p);