MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / AST_Free

Function AST_Free

src/ast/ast.c:825–858  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

823}
824
825void AST_Free
826(
827 AST *ast
828) {
829 if(ast == NULL) return;
830
831 int ref_count = AST_DecRefCount(ast);
832
833 // check if the ast has additional copies
834 if(ref_count == 0) {
835 // free and nullify parameters parse result if needed
836 // after execution, as they are only save for the execution lifetime
837 if(ast->params_parse_result != NULL) {
838 parse_result_free(ast->params_parse_result);
839 }
840
841 // no valid references, the struct can be disposed completely
842 if(ast->free_root) {
843 // this is a generated AST, free its root node
844 cypher_astnode_free((cypher_astnode_t *) ast->root);
845 } else {
846 // this is the master AST
847 // free the annotation contexts that have been constructed
848 AST_AnnotationCtxCollection_Free(ast->anot_ctx_collection);
849 parse_result_free(ast->parse_result);
850 }
851
852 if(ast->referenced_entities) raxFree(ast->referenced_entities);
853
854 rm_free(ast->ref_count);
855 }
856
857 rm_free(ast);
858}
859

Callers 15

ExecutionCtx_FromQueryFunction · 0.85
ExecutionCtx_FreeFunction · 0.85
test_BothDirectionsFunction · 0.85
test_SingleNodeFunction · 0.85
test_ShareableEntityFunction · 0.85

Calls 4

AST_DecRefCountFunction · 0.85
parse_result_freeFunction · 0.85
rm_freeFunction · 0.85

Tested by 15

test_BothDirectionsFunction · 0.68
test_SingleNodeFunction · 0.68
test_ShareableEntityFunction · 0.68
test_VariableLengthFunction · 0.68
test_ExpressionExecuteFunction · 0.68