Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(scanner): prefer abort over exit #111

Merged
merged 1 commit into from
Feb 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ typedef struct {

static Stack *new_stack() {
Delimiter *arr = malloc(TREE_SITTER_SERIALIZATION_BUFFER_SIZE);
if (arr == NULL) exit(1);
if (arr == NULL) abort();
Stack *stack = malloc(sizeof(Stack));
if (stack == NULL) exit(1);
if (stack == NULL) abort();
stack->arr = arr;
stack->len = 0;
return stack;
Expand All @@ -60,12 +60,12 @@ static void free_stack(Stack *stack) {
}

static void push(Stack *stack, char chr, bool triple) {
if (stack->len >= TREE_SITTER_SERIALIZATION_BUFFER_SIZE) exit(1);
if (stack->len >= TREE_SITTER_SERIALIZATION_BUFFER_SIZE) abort();
stack->arr[stack->len++] = (Delimiter)(triple ? (chr + 1) : chr);
}

static Delimiter pop(Stack *stack) {
if (stack->len == 0) exit(1);
if (stack->len == 0) abort();
return stack->arr[stack->len--];
}

Expand Down
Loading