Merge pull request #83 from tree-sitter/ref-counts

Increase size of ref_counts and add assertions
This commit is contained in:
Max Brunsfeld 2017-06-29 10:15:51 -07:00 committed by GitHub
commit 5e3818882b
3 changed files with 5 additions and 3 deletions

View file

@ -26,7 +26,7 @@ struct StackNode {
Length position;
StackLink links[MAX_LINK_COUNT];
short unsigned int link_count;
short unsigned int ref_count;
uint32_t ref_count;
unsigned error_cost;
unsigned error_count;
};
@ -65,8 +65,9 @@ struct Stack {
static void stack_node_retain(StackNode *self) {
if (!self)
return;
assert(self->ref_count != 0);
assert(self->ref_count > 0);
self->ref_count++;
assert(self->ref_count != 0);
}
static void stack_node_release(StackNode *self, StackNodeArray *pool) {

View file

@ -232,6 +232,7 @@ Tree *ts_tree_make_error_node(TreeArray *children) {
void ts_tree_retain(Tree *self) {
assert(self->ref_count > 0);
self->ref_count++;
assert(self->ref_count != 0);
}
void ts_tree_release(Tree *self) {

View file

@ -45,7 +45,7 @@ typedef struct Tree {
TSLexMode lex_mode;
} first_leaf;
unsigned short ref_count;
uint32_t ref_count;
bool visible : 1;
bool named : 1;
bool extra : 1;