From 3ad5493758227a3d273dea66061fa254f14c886d Mon Sep 17 00:00:00 2001 From: "kr.angelov" Date: Wed, 13 Jun 2012 05:49:30 +0000 Subject: Use a separated tag for meta productions in the robust parser. This cleans up the code a lot --- src/runtime/c/gu/seq.c | 9 +++++++-- src/runtime/c/gu/seq.h | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src/runtime/c/gu') diff --git a/src/runtime/c/gu/seq.c b/src/runtime/c/gu/seq.c index fda1be99c..d994d5990 100644 --- a/src/runtime/c/gu/seq.c +++ b/src/runtime/c/gu/seq.c @@ -66,7 +66,12 @@ gu_make_buf(size_t elem_size, GuPool* pool) return buf; } -static const GuWord gu_empty_seq[2] = {0, 0}; +static const GuWord gu_empty_seq_[2] = {0, 0}; + +GuSeq +gu_empty_seq() { + return (GuSeq) { gu_tagged((void*)&gu_empty_seq_[1], 0) }; +} GuSeq gu_make_seq(size_t elem_size, size_t length, GuPool* pool) @@ -76,7 +81,7 @@ gu_make_seq(size_t elem_size, size_t length, GuPool* pool) void* buf = gu_malloc(pool, size); return (GuSeq) { gu_tagged(buf, length) }; } else if (size == 0) { - return (GuSeq) { gu_tagged((void*)&gu_empty_seq[1], 0) }; + return gu_empty_seq(); } else { void* buf = gu_malloc_prefixed(pool, gu_alignof(GuWord), diff --git a/src/runtime/c/gu/seq.h b/src/runtime/c/gu/seq.h index b21933a65..52b2bfc7e 100644 --- a/src/runtime/c/gu/seq.h +++ b/src/runtime/c/gu/seq.h @@ -9,6 +9,9 @@ typedef struct GuBuf GuBuf; typedef GuOpaque() GuSeq; +GuSeq +gu_empty_seq(); + GuSeq gu_make_seq(size_t elem_size, size_t len, GuPool* pool); -- cgit v1.2.3