summaryrefslogtreecommitdiffstats
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
commit935c9e98cbeac5d3cacd1857d42e5c98302c11a8 (patch)
treefa3a926b24d7fcab7c0ba8a89340b4462bcce261 /parse.y
parent4b20956c38c92b892a49644d4eee04ef99a4b6eb (diff)
downloadruby-935c9e98cbeac5d3cacd1857d42e5c98302c11a8.tar.gz
ruby-935c9e98cbeac5d3cacd1857d42e5c98302c11a8.tar.xz
ruby-935c9e98cbeac5d3cacd1857d42e5c98302c11a8.zip
* parse.y (NEWHEAP, ADD2HEAP): set count after pointer was set.
fixed: [ruby-dev:27896] git-svn-id: http://svn.ruby-lang.org/repos/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 aafc821a8..df89471e4 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