Skip to content

Commit

Permalink
feat(scanner): use alloc header
Browse files Browse the repository at this point in the history
  • Loading branch information
ObserverOfTime authored and amaanq committed Apr 4, 2024
1 parent 075886a commit 8a64c2d
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/scanner.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
#include "tree_sitter/alloc.h"
#include "tree_sitter/parser.h"

#include <assert.h>
#include <string.h>
#include <wctype.h>

#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
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}

0 comments on commit 8a64c2d

Please sign in to comment.