Skip to content

Commit

Permalink
Update synctex_parser.c (#64)
Browse files Browse the repository at this point in the history
Less recursion when nodes are freed.
  • Loading branch information
jlaurens committed Mar 9, 2024
1 parent 81b5c30 commit 65591ce
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions synctex_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -899,18 +899,22 @@ SYNCTEX_INLINE static void _synctex_will_free(synctex_node_p node) {
* - note: a node is meant to own its child and sibling.
* It is not owned by its parent, unless it is its first child.
* This destructor is for all nodes with children.
*
* Recursion only occurs from parent to children, which means
* that there is a maximum depth determined by the calling stack size.
* This is not managed.
*/
static void _synctex_free_node(synctex_node_p node) {
if (node) {
while (node) {
synctex_node_p sibling = __synctex_tree_sibling(node);
SYNCTEX_SCANNER_REMOVE_HANDLE_TO(node);
SYNCTEX_WILL_FREE(node);
synctex_node_free(__synctex_tree_sibling(node));
synctex_node_free(_synctex_tree_child(node));
_synctex_free(node);
node = sibling;
}
return;
}
/**
}/**
* Free the given handle.
* - parameter node: of type synctex_node_p
* - note: a node is meant to own its child and sibling.
Expand Down

0 comments on commit 65591ce

Please sign in to comment.