Skip to content

Commit

Permalink
Use tree-sitter allocation functions (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
314eter committed Mar 30, 2024
1 parent 61110c1 commit 0b12614
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions include/scanner.h
@@ -1,6 +1,7 @@
#ifndef TREE_SITTER_OCAML_SCANNER_H_
#define TREE_SITTER_OCAML_SCANNER_H_

#include "tree_sitter/alloc.h"
#include "tree_sitter/parser.h"

#include <assert.h>
Expand Down Expand Up @@ -39,7 +40,7 @@ static inline void quoted_string_id_resize(Scanner *scanner,

scanner->quoted_string_id_capacity = capacity;
scanner->quoted_string_id =
realloc(scanner->quoted_string_id, capacity * sizeof(char));
ts_realloc(scanner->quoted_string_id, capacity * sizeof(char));
}

static inline void quoted_string_id_assign(Scanner *scanner, const char *buffer,
Expand Down Expand Up @@ -303,13 +304,13 @@ static bool scan_comment(Scanner *scanner, TSLexer *lexer) {
}

static Scanner *create() {
Scanner *scanner = calloc(1, sizeof(Scanner));
Scanner *scanner = ts_calloc(1, sizeof(Scanner));
return scanner;
}

static void destroy(Scanner *scanner) {
free(scanner->quoted_string_id);
free(scanner);
ts_free(scanner->quoted_string_id);
ts_free(scanner);
}

static unsigned serialize(Scanner *scanner, char *buffer) {
Expand Down

0 comments on commit 0b12614

Please sign in to comment.