summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-09 06:12:17 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-09 06:12:17 +0000
commit58823392b465ef50819f36994be5a75a91da6ecc (patch)
treeafe8e53929c163c73b3eb678b5946db5dfb0e77b /parse.y
parent75d5cf55dea0c1351ebd37d432545935698c5c18 (diff)
gc.c (rb_imemo_alloc_new): improve the API interface
rb_imemo_alloc_new returns rb_imemo_alloc_t*, but took VALUEs, which is inconsistent. To make the intention clear, it now takes only a pointer to the buffer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y19
1 files changed, 10 insertions, 9 deletions
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);
}