/** @brief Deallocate an Expression. @param exp Pointer to the Expression to be deallocated. Free the strings owned by the Expression. Put the Expressions itself into a free list. */ static void expressionFree( Expression* exp ) { if( exp ) { free( exp->literal ); exp->literal = NULL; free( exp->table_alias ); exp->table_alias = NULL; free( exp->column_name ); exp->column_name = NULL; if( exp->left_operand ) { expressionFree( exp->left_operand ); exp->left_operand = NULL; } free( exp->op ); exp->op = NULL; if( exp->right_operand ) { expressionFree( exp->right_operand ); exp->right_operand = NULL; } if( exp->subquery ) { storedQFree( exp->subquery ); exp->subquery = NULL; } exp->next = free_expression_list; free_expression_list = exp; } }
/** @brief Free a CachedQuery @param Pointer to the CachedQuery to be freed. */ static void free_cached_query( char* key, void* data ) { if( data ) { CachedQuery* cached_query = data; buildSQLStateFree( cached_query->state ); storedQFree( cached_query->query ); } }
static void freeQSeqList( QSeq* seq ) { if( !seq ) return; QSeq* first = seq; while( seq ) { storedQFree( seq->child_query ); seq->child_query = NULL; if( seq->next ) seq = seq->next; else { seq->next = free_qseq_list; seq = NULL; } } free_qseq_list = first; }
/** @brief Deallocate a FromRelation. @param fr Pointer to the FromRelation to be freed. Free the strings that the FromRelation owns. The FromRelation itself goes onto a free list for potential reuse. */ static void fromRelationFree( FromRelation* fr ) { if( fr ) { free( fr->table_name ); fr->table_name = NULL; free( fr->class_name ); fr->class_name = NULL; if( fr->subquery ) { storedQFree( fr->subquery ); fr->subquery = NULL; } free( fr->table_alias ); fr->table_alias = NULL; if( fr->on_clause ) { expressionFree( fr->on_clause ); fr->on_clause = NULL; } joinListFree( fr->join_list ); fr->join_list = NULL; fr->next = free_from_relation_list; free_from_relation_list = fr; } }