summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-11-30 14:53:25 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-11-30 14:53:25 +0000
commite753c0e88e07f21367a59efb03f89fffeed99b18 (patch)
treefa3a926b24d7fcab7c0ba8a89340b4462bcce261 /parse.y
parent16732201b2e5fe58087c2d303e773cc5e915cb6d (diff)
* parse.y (NEWHEAP, ADD2HEAP): set count after pointer was set.
fixed: [ruby-dev:27896] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y22
1 files changed, 14 insertions, 8 deletions
diff --git a/parse.y b/parse.y
index aafc821a87..df89471e46 100644
--- a/parse.y
+++ b/parse.y
@@ -6235,25 +6235,30 @@ rb_lastline_set(val)
#ifdef YYMALLOC
#define HEAPCNT(n, size) ((n) * (size) / sizeof(YYSTYPE))
-#define NEWHEAP(cnt) rb_node_newnode(NODE_ALLOCA, 0, (VALUE)parser_heap, cnt)
-#define ADD2HEAP(n, ptr) ((parser_heap = (n))->u1.node = (ptr))
+#define NEWHEAP() rb_node_newnode(NODE_ALLOCA, 0, (VALUE)parserp->heap, 0)
+#define ADD2HEAP(n, c, p) ((parserp->heap = (n))->u1.node = (p), \
+ (n)->u3.cnt = (c), (p))
static void *
rb_parser_malloc(size)
size_t size;
{
- NODE *n = NEWHEAP(HEAPCNT(1, size));
+ size_t cnt = HEAPCNT(1, size);
+ NODE *n = NEWHEAP();
+ void *ptr = xmalloc(size);
- return ADD2HEAP(n, xmalloc(size));
+ return ADD2HEAP(n, cnt, ptr);
}
static void *
rb_parser_calloc(nelem, size)
size_t nelem, size;
{
- NODE *n = NEWHEAP(HEAPCNT(nelem, size));
+ size_t cnt = HEAPCNT(nelem, size);
+ NODE *n = NEWHEAP();
+ void *ptr = xcalloc(nelem, size);
- return ADD2HEAP(n, xcalloc(nelem, size));
+ return ADD2HEAP(n, cnt, ptr);
}
static void *
@@ -6273,8 +6278,9 @@ rb_parser_realloc(ptr, size)
}
} while ((n = n->u2.node) != NULL);
}
- n = NEWHEAP(cnt);
- return ADD2HEAP(n, xrealloc(ptr, size));
+ n = NEWHEAP();
+ ptr = xrealloc(ptr, size);
+ return ADD2HEAP(n, cnt, ptr);
}
static void