aboutsummaryrefslogtreecommitdiffstats
path: root/gc.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-25 13:38:53 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-25 13:38:53 +0000
commit033beeb68a73ae7ff7c8d1644d27939aedabe3a5 (patch)
treeaf14c5853bae480e18e34f71a16a025e5d315668 /gc.c
parent2e6e5394dc12b4f9f96cf7016957eef9255a9511 (diff)
downloadruby-033beeb68a73ae7ff7c8d1644d27939aedabe3a5.tar.gz
Refactoring by adding `rb_imemo_alloc_new` to create imemo_alloc buffer
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/gc.c b/gc.c
index 6e32997b8e..2b9d5b1029 100644
--- a/gc.c
+++ b/gc.c
@@ -8110,20 +8110,25 @@ ruby_mimfree(void *ptr)
free(mem);
}
+rb_imemo_alloc_t *
+rb_imemo_alloc_new(VALUE v1, VALUE v2, VALUE v3, VALUE v0)
+{
+ VALUE s = rb_imemo_new(imemo_alloc, v1, v2, v3, v0);
+ rb_gc_writebarrier_unprotect(s);
+ return (rb_imemo_alloc_t *)s;
+}
+
void *
rb_alloc_tmp_buffer_with_count(volatile VALUE *store, size_t size, size_t cnt)
{
- VALUE s;
- rb_imemo_alloc_t *a;
+ rb_imemo_alloc_t *s;
void *ptr;
- s = rb_imemo_new(imemo_alloc, 0, 0, 0, 0);
- rb_gc_writebarrier_unprotect(s);
+ s = rb_imemo_alloc_new(0, 0, 0, 0);
ptr = ruby_xmalloc0(size);
- a = (rb_imemo_alloc_t*)s;
- a->ptr = (VALUE*)ptr;
- a->cnt = cnt;
- *store = s;
+ s->ptr = (VALUE*)ptr;
+ s->cnt = cnt;
+ *store = (VALUE)s;
return ptr;
}