From 8a64c2d6dd25a570dc8f6384b181c019a6ac1aa9 Mon Sep 17 00:00:00 2001 From: ObserverOfTime Date: Sun, 31 Mar 2024 15:40:50 +0300 Subject: [PATCH] feat(scanner): use alloc header --- src/scanner.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/scanner.c b/src/scanner.c index 7dfb97b..32b4893 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -1,13 +1,10 @@ +#include "tree_sitter/alloc.h" #include "tree_sitter/parser.h" #include #include #include -#if __STDC_VERSION__ < 201112L -#define static_assert(cnd, msg) assert(cnd && msg) -#endif // __STDC_VERSION__ < 201112L - enum TokenType { RAW_STRING_DELIMITER, RAW_STRING_CONTENT }; /// The spec limits delimiters to 16 chars @@ -98,7 +95,7 @@ static bool scan_raw_string_content(Scanner *scanner, TSLexer *lexer) { } void *tree_sitter_cpp_external_scanner_create() { - Scanner *scanner = (Scanner *)calloc(1, sizeof(Scanner)); + Scanner *scanner = (Scanner *)ts_calloc(1, sizeof(Scanner)); memset(scanner, 0, sizeof(Scanner)); return scanner; } @@ -145,5 +142,5 @@ void tree_sitter_cpp_external_scanner_deserialize(void *payload, const char *buf void tree_sitter_cpp_external_scanner_destroy(void *payload) { Scanner *scanner = (Scanner *)payload; - free(scanner); + ts_free(scanner); }