summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gc.c7
-rw-r--r--internal.h2
-rw-r--r--parse.y19
3 files changed, 14 insertions, 14 deletions
diff --git a/gc.c b/gc.c
index b9c1305060..210bef053f 100644
--- a/gc.c
+++ b/gc.c
@@ -2025,10 +2025,10 @@ rb_imemo_new(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0)
}
rb_imemo_alloc_t *
-rb_imemo_alloc_new(VALUE v1, VALUE v2, VALUE v3, VALUE v0)
+rb_imemo_alloc_new(void *buf)
{
VALUE flags = T_IMEMO | (imemo_alloc << FL_USHIFT);
- return (rb_imemo_alloc_t *)newobj_of(v0, flags, v1, v2, v3, FALSE);
+ return (rb_imemo_alloc_t *)newobj_of(0, flags, (VALUE)buf, 0, 0, FALSE);
}
#if IMEMO_DEBUG
@@ -8125,9 +8125,8 @@ rb_alloc_tmp_buffer_with_count(volatile VALUE *store, size_t size, size_t cnt)
rb_imemo_alloc_t *s;
void *ptr;
- s = rb_imemo_alloc_new(0, 0, 0, 0);
ptr = ruby_xmalloc0(size);
- s->ptr = (VALUE*)ptr;
+ s = rb_imemo_alloc_new(ptr);
s->cnt = cnt;
*store = (VALUE)s;
return ptr;
diff --git a/internal.h b/internal.h
index 6cab3d4ffd..304dcc1910 100644
--- a/internal.h
+++ b/internal.h
@@ -960,7 +960,7 @@ typedef struct rb_imemo_alloc_struct {
size_t cnt; /* buffer size in VALUE */
} rb_imemo_alloc_t;
-rb_imemo_alloc_t *rb_imemo_alloc_new(VALUE, VALUE, VALUE, VALUE);
+rb_imemo_alloc_t *rb_imemo_alloc_new(void *buf);
void rb_strterm_mark(VALUE obj);
diff --git a/parse.y b/parse.y
index 5820e7f73d..30d0860851 100644
--- a/parse.y
+++ b/parse.y
@@ -2505,7 +2505,7 @@ primary : literal
NODE *args, *scope, *internal_var = NEW_DVAR(id, &@2);
ID *tbl = ALLOC_N(ID, 2);
tbl[0] = 1 /* length of local var table */; tbl[1] = id /* internal id */;
- add_mark_object(p, (VALUE)rb_imemo_alloc_new((VALUE)tbl, 0, 0, 0));
+ add_mark_object(p, (VALUE)rb_imemo_alloc_new(tbl));
switch (nd_type($2)) {
case NODE_LASGN:
@@ -9988,7 +9988,7 @@ new_args_tail(struct parser_params *p, NODE *kw_args, ID kw_rest_arg, ID block,
NODE *node;
args = ZALLOC(struct rb_args_info);
- add_mark_object(p, (VALUE)rb_imemo_alloc_new((VALUE)args, 0, 0, 0));
+ add_mark_object(p, (VALUE)rb_imemo_alloc_new(args));
node = NEW_NODE(NODE_ARGS, 0, 0, args, &NULL_LOC);
if (p->error_p) return node;
@@ -10350,7 +10350,7 @@ local_tbl(struct parser_params *p)
if (--j < cnt) REALLOC_N(buf, ID, (cnt = j) + 1);
buf[0] = cnt;
- add_mark_object(p, (VALUE)rb_imemo_alloc_new((VALUE)buf, 0, 0, 0));
+ add_mark_object(p, (VALUE)rb_imemo_alloc_new(buf));
return buf;
}
@@ -10968,16 +10968,15 @@ rb_parser_set_yydebug(VALUE self, VALUE flag)
#ifndef RIPPER
#ifdef YYMALLOC
#define HEAPCNT(n, size) ((n) * (size) / sizeof(YYSTYPE))
-#define NEWHEAP() rb_imemo_alloc_new(0, (VALUE)p->heap, 0, 0)
-#define ADD2HEAP(new, cnt, ptr) ((p->heap = (new))->ptr = (ptr), \
- (new)->cnt = (cnt), (ptr))
+#define ADD2HEAP(new, cnt, ptr) (p->heap = (new), (new)->cnt = (cnt), (ptr))
void *
rb_parser_malloc(struct parser_params *p, size_t size)
{
size_t cnt = HEAPCNT(1, size);
- rb_imemo_alloc_t *n = NEWHEAP();
void *ptr = xmalloc(size);
+ rb_imemo_alloc_t *n = rb_imemo_alloc_new(ptr);
+ n->next = p->heap;
return ADD2HEAP(n, cnt, ptr);
}
@@ -10986,8 +10985,9 @@ void *
rb_parser_calloc(struct parser_params *p, size_t nelem, size_t size)
{
size_t cnt = HEAPCNT(nelem, size);
- rb_imemo_alloc_t *n = NEWHEAP();
void *ptr = xcalloc(nelem, size);
+ rb_imemo_alloc_t *n = rb_imemo_alloc_new(ptr);
+ n->next = p->heap;
return ADD2HEAP(n, cnt, ptr);
}
@@ -11007,8 +11007,9 @@ rb_parser_realloc(struct parser_params *p, void *ptr, size_t size)
}
} while ((n = n->next) != NULL);
}
- n = NEWHEAP();
ptr = xrealloc(ptr, size);
+ n = rb_imemo_alloc_new(ptr);
+ n->next = p->heap;
return ADD2HEAP(n, cnt, ptr);
}