Skip to content

Commit

Permalink
val: Don't decref null values
Browse files Browse the repository at this point in the history
  • Loading branch information
obiwac committed Sep 8, 2024
1 parent fafec3d commit f018a7b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions flamingo/val.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ static void val_free(flamingo_val_t* val) {
}

static flamingo_val_t* val_decref(flamingo_val_t* val) {
if (val == NULL) {
return NULL;
}

val->ref_count--;

if (val->ref_count > 0) {
Expand Down
2 changes: 2 additions & 0 deletions questions.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ I'm keeping track of these so I don't forget why I did something a certain way a
*Q:* Should I really be passing TSNode everywhere instead of TSNode*? It feels like this is prone to me being like "oh, well, the TSNode type is probably hiding a pointer if it's being used as an argument, so I don't have to worry about out-of-scope usage".

*A:* Yes. Tree-sitter passes them as values, so be consistent with that.

*Q:* Do gently detached scopes need to be freed or are they already?

0 comments on commit f018a7b

Please sign in to comment.