summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkr.angelov <kr.angelov@gmail.com>2012-02-29 13:41:59 +0000
committerkr.angelov <kr.angelov@gmail.com>2012-02-29 13:41:59 +0000
commitb0545490826637a610a17c3aeb831848ae0ae5f7 (patch)
tree75a2eced659fca21a680d1ba430be93b88dca3b8 /src
parent6f42f58f71e54ffdd89cb4d53c68e9212eb5a0ee (diff)
libpgf: the choice object should remember integers instead of single bytes
Diffstat (limited to 'src')
-rw-r--r--src/runtime/c/gu/choice.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/runtime/c/gu/choice.c b/src/runtime/c/gu/choice.c
index b1e4a3a5e..ddf0bb68b 100644
--- a/src/runtime/c/gu/choice.c
+++ b/src/runtime/c/gu/choice.c
@@ -12,7 +12,7 @@ GuChoice*
gu_new_choice(GuPool* pool)
{
GuChoice* ch = gu_new(GuChoice, pool);
- ch->path = gu_new_buf(uint8_t, pool);
+ ch->path = gu_new_buf(size_t, pool);
ch->path_idx = 0;
return ch;
}
@@ -38,17 +38,16 @@ int
gu_choice_next(GuChoice* ch, int n_choices)
{
gu_assert(n_choices >= 0);
- gu_require(n_choices <= UINT8_MAX);
gu_assert(ch->path_idx <= gu_buf_length(ch->path));
if (n_choices == 0) {
return -1;
}
int i = 0;
if (gu_buf_length(ch->path) > ch->path_idx) {
- i = (int) gu_buf_get(ch->path, uint8_t, ch->path_idx);
+ i = (int) gu_buf_get(ch->path, size_t, ch->path_idx);
gu_assert(i <= n_choices);
} else {
- gu_buf_push(ch->path, uint8_t, n_choices);
+ gu_buf_push(ch->path, size_t, n_choices);
i = n_choices;
}
int ret = (i == 0) ? -1 : n_choices - i;
@@ -63,9 +62,9 @@ gu_choice_advance(GuChoice* ch)
gu_assert(ch->path_idx <= gu_buf_length(ch->path));
while (gu_buf_length(ch->path) > ch->path_idx) {
- uint8_t last = gu_buf_pop(ch->path, uint8_t);
+ size_t last = gu_buf_pop(ch->path, size_t);
if (last > 1) {
- gu_buf_push(ch->path, uint8_t, last-1);
+ gu_buf_push(ch->path, size_t, last-1);
return true;
}
}