Merge branch 'master' of yap.dcc.fc.up.pt:yap-6

This commit is contained in:
Vitor Santos Costa 2010-03-30 12:48:56 +01:00
commit ecf5c572ab

View File

@ -1404,10 +1404,11 @@ void private_completion(sg_fr_ptr sg_fr) {
#ifdef GLOBAL_TRIE #ifdef GLOBAL_TRIE
void free_subgoal_trie_branch(sg_node_ptr current_node, int nodes_left, int position) { void free_subgoal_trie_branch(sg_node_ptr current_node, int nodes_left, int position) {
if (nodes_left != 1) if (nodes_left) {
free_subgoal_trie_branch(TrNode_child(current_node), nodes_left - 1, TRAVERSE_POSITION_FIRST); free_subgoal_trie_branch(TrNode_child(current_node), nodes_left - 1, TRAVERSE_POSITION_FIRST);
#else #else
void free_subgoal_trie_branch(sg_node_ptr current_node, int nodes_left, int nodes_extra, int position) { void free_subgoal_trie_branch(sg_node_ptr current_node, int nodes_left, int nodes_extra, int position) {
if (nodes_left) {
int current_nodes_left = 0, current_nodes_extra = 0; int current_nodes_left = 0, current_nodes_extra = 0;
/* save current state if first sibling node */ /* save current state if first sibling node */
@ -1455,24 +1456,8 @@ void free_subgoal_trie_branch(sg_node_ptr current_node, int nodes_left, int node
nodes_left += ArityOfFunctor(f) - 1; nodes_left += ArityOfFunctor(f) - 1;
} }
} }
if (nodes_left)
free_subgoal_trie_branch(TrNode_child(current_node), nodes_left, nodes_extra, TRAVERSE_POSITION_FIRST); free_subgoal_trie_branch(TrNode_child(current_node), nodes_left, nodes_extra, TRAVERSE_POSITION_FIRST);
#endif /* GLOBAL_TRIE */ #endif /* GLOBAL_TRIE */
else {
sg_fr_ptr sg_fr;
ans_node_ptr ans_node;
sg_fr = (sg_fr_ptr) TrNode_sg_fr(current_node);
free_answer_trie_hash_chain(SgFr_hash_chain(sg_fr));
ans_node = SgFr_answer_trie(sg_fr);
if (TrNode_child(ans_node))
free_answer_trie_branch(TrNode_child(ans_node), TRAVERSE_POSITION_FIRST);
FREE_ANSWER_TRIE_NODE(ans_node);
#ifdef LIMIT_TABLING
remove_from_global_sg_fr_list(sg_fr);
#endif /* LIMIT_TABLING */
FREE_SUBGOAL_FRAME(sg_fr);
}
if (position == TRAVERSE_POSITION_FIRST) { if (position == TRAVERSE_POSITION_FIRST) {
sg_node_ptr next_node = TrNode_next(current_node); sg_node_ptr next_node = TrNode_next(current_node);
DECREMENT_GLOBAL_TRIE_REFS(TrNode_entry(current_node)); DECREMENT_GLOBAL_TRIE_REFS(TrNode_entry(current_node));
@ -1495,6 +1480,21 @@ void free_subgoal_trie_branch(sg_node_ptr current_node, int nodes_left, int node
DECREMENT_GLOBAL_TRIE_REFS(TrNode_entry(current_node)); DECREMENT_GLOBAL_TRIE_REFS(TrNode_entry(current_node));
FREE_SUBGOAL_TRIE_NODE(current_node); FREE_SUBGOAL_TRIE_NODE(current_node);
} }
} else {
sg_fr_ptr sg_fr;
ans_node_ptr ans_node;
sg_fr = (sg_fr_ptr) current_node;
free_answer_trie_hash_chain(SgFr_hash_chain(sg_fr));
ans_node = SgFr_answer_trie(sg_fr);
if (TrNode_child(ans_node))
free_answer_trie_branch(TrNode_child(ans_node), TRAVERSE_POSITION_FIRST);
FREE_ANSWER_TRIE_NODE(ans_node);
#ifdef LIMIT_TABLING
remove_from_global_sg_fr_list(sg_fr);
#endif /* LIMIT_TABLING */
FREE_SUBGOAL_FRAME(sg_fr);
}
return; return;
} }