From 9d0835edbfdb0acb5f4483cdf3da987245daba21 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 18 Jan 2016 10:27:23 -0800 Subject: [PATCH] Return non-const string from ts_node_string The caller should free the string. --- include/tree_sitter/runtime.h | 2 +- src/runtime/node.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/tree_sitter/runtime.h b/include/tree_sitter/runtime.h index 59e73cd4..bbf9dff7 100644 --- a/include/tree_sitter/runtime.h +++ b/include/tree_sitter/runtime.h @@ -58,7 +58,7 @@ size_t ts_node_end_byte(TSNode); TSPoint ts_node_end_point(TSNode); TSSymbol ts_node_symbol(TSNode); const char *ts_node_name(TSNode, const TSDocument *); -const char *ts_node_string(TSNode, const TSDocument *); +char *ts_node_string(TSNode, const TSDocument *); bool ts_node_eq(TSNode, TSNode); bool ts_node_is_named(TSNode); bool ts_node_has_changes(TSNode); diff --git a/src/runtime/node.c b/src/runtime/node.c index 1597cccd..519910a0 100644 --- a/src/runtime/node.c +++ b/src/runtime/node.c @@ -206,7 +206,7 @@ const char *ts_node_name(TSNode self, const TSDocument *document) { return document->parser.language->symbol_names[ts_node__tree(self)->symbol]; } -const char *ts_node_string(TSNode self, const TSDocument *document) { +char *ts_node_string(TSNode self, const TSDocument *document) { return ts_tree_string(ts_node__tree(self), document->parser.language->symbol_names, false); }