void table_Free(TABLE table) { int i; if (table != table_Null()) { for (i = -table_GetVarbound(table); i <= table_GetOpbound(table); i++) table_FreeTermarray( table_GetChild(table_GetTermarray(table) + i), table_GetTermbound(table) + 1 ); memory_Free( table_GetTermarray(table) - table_GetVarbound(table), (table_GetOpbound(table) + table_GetVarbound(table) + 1) * sizeof(struct termarray) ); memory_Free( table_GetPoss(table), (table_GetTermbound(table) + 1) * sizeof(TERMARRAY) ); memory_Free( table_GetPosstamps(table), (table_GetTermbound(table) + 1) * sizeof(int) ); memory_Free(table, sizeof(struct table)); } }
void tab_PathDelete(TABPATH TabPath) /************************************************************** INPUT: A tableau path. RETURNS: Nothing. EFFECTS: The path is deleted. ***************************************************************/ { memory_Free(TabPath->Path, (TabPath->MaxLength+1)*sizeof(TABLEAU)); memory_Free(TabPath, sizeof(TABPATH_NODE)); }
void graph_Delete(GRAPH Graph) /************************************************************** INPUT: A graph. RETURNS: Nothing. EFFECT: All memory required by the graph and its nodes is freed. ***************************************************************/ { for ( ; !list_Empty(Graph->nodes); Graph->nodes = list_Pop(Graph->nodes)) { list_Delete(graph_NodeNeighbors(list_Car(Graph->nodes))); memory_Free(list_Car(Graph->nodes), sizeof(GRAPHNODE_STRUCT)); } memory_Free(Graph, sizeof(GRAPH_STRUCT)); }
void symbol_LowerSignature(void) /************************************************************** INPUT: None. RETURNS: Nothing. EFFECT: Any predicate or function symbol in the signature that starts with a capital letter is prefixed with "ss" ***************************************************************/ { int Index; SIGNATURE Entry; SYMBOL Info; char* String; for (Index = 1; Index < symbol_ACTINDEX; Index++) { Entry = symbol_Signature(Index); if (Entry != NULL) { Info = Entry->info; if (symbol_IsPredicate(Info) || symbol_IsFunction(Info)) { String = Entry->name; if ('A' <= String[0] && String[0] <= 'Z') { char* New; New = (char *)memory_Malloc(symbol__SYMBOLMAXLEN); strcpy(&(New[2]),String); New[0] = New[1] = 's'; /* prefix "ss" */ Entry->name = New; memory_Free(String,symbol__SYMBOLMAXLEN); } } } } }
void litptr_Delete(LITPTR lit_ptr) /********************************************************** INPUT: A pointer to LITPTR. MEMORY: Deletes the LITPTR and frees the storage. ***********************************************************/ { int n,i; n = litptr_Length(lit_ptr); if (n > 0) { for (i = 0; i < n; i++) literal_Delete(litptr_Literal(lit_ptr,i)); memory_Free(lit_ptr->litptr, sizeof(CLITERAL) * n); memory_Free(lit_ptr, sizeof(LITPTR_NODE)); } else memory_Free(lit_ptr, sizeof(LITPTR_NODE)); }
void hsh_Delete(HASH H) /************************************************************** INPUT: A hasharray EFFECT: Deletes all information stored in the array and the array itself. Keys and data items are not deleted ! ***************************************************************/ { hsh_Reset(H); memory_Free(H, sizeof(LIST) * hsh__SIZE); }
void symbol_FreeAllSymbols(void) /************************************************************** INPUT: None. RETURNS: Nothing. EFFECTS: Frees all generated symbols ***************************************************************/ { if (symbol_SignatureExists()) { int Index; SIGNATURE S; for (Index = 1; Index < symbol_ACTINDEX; Index++) { S = symbol_Signature(Index); if (S != NULL) symbol_FreeSignature(S); } memory_Free(symbol_SIGNATURE, sizeof(SIGNATURE[symbol__MAXSIGNATURE])); } memory_Free(symbol_VARSTRING, symbol__SYMBOLMAXLEN); list_Delete(symbol_FREEDSYMBOLS); }
static LIST tab_DeleteFlat(TABLEAU T) /************************************************************** INPUT: A tableau RETURNS: The list of its clauses on the first level of the tableau EFFECTS: Frees the root tableau node. ***************************************************************/ { LIST Clauses; Clauses = tab_Clauses(T); memory_Free(T, sizeof(TABLEAU_NODE)); return Clauses; }
static void table_FreeTermarray(TERMARRAY ta, int size) /*************************************************************** INPUT: the termarray to free and its size EFFECT: recursively frees the tree structure allocated for the signature array ***************************************************************/ { int i; if (ta) { for (i = 0; i < size; i++) table_FreeTermarray(table_GetChild(ta + i), size); memory_Free(ta, size * sizeof(struct termarray)); } }
void cont_Free(void) /********************************************************** INPUT: None. RETURNS: None. EFFECT: Frees internal structures of the unify module. ********************************************************/ { cont_Check(); while (cont_NOOFCONTEXTS > 0) cont_Delete(list_Car(cont_LISTOFCONTEXTS)); /* Decreases NOOFCONTEXTS */ cont_BINDINGS = 0; memory_Free(cont_INSTANCECONTEXT, sizeof(CONTEXT_NODE)); }
static void dp_FPrintDFGProof(LIST Clauses, const char *FilePrefix, FLAGSTORE Flags, PRECEDENCE Precedence) /********************************************************* INPUT: A list of clauses representing a proof, a string indicating a file name prefix, a flag store and a precedence. RETURNS: void. EFFECT: Outputs the proof in DFG proof format to <FilePrefix>.prf **********************************************************/ { FILE *Output; CLAUSE Clause; LIST AxClauses,ConClauses,ProofClauses,Scan; char *name; AxClauses = ConClauses = ProofClauses = list_Nil(); name = memory_Malloc(sizeof(char)*(strlen(FilePrefix)+5)); sprintf(name,"%s.prf", FilePrefix); Output = misc_OpenFile(name,"w"); fputs("begin_problem(Unknown).\n\n", Output); fputs("list_of_descriptions.\n", Output); fputs("name({*", Output); fputs(FilePrefix, Output); fputs("*}).\n", Output); fputs("author({*SPASS ", Output); fputs(misc_VERSION, Output); fputs("*}).\n", Output); fputs("status(unsatisfiable).\n", Output); fputs("description({*File generated by SPASS containing a proof.*}).\n", Output); fputs("end_of_list.\n\n", Output); fputs("list_of_symbols.\n", Output); fol_FPrintDFGSignature(Output); fputs("end_of_list.\n\n", Output); for (Scan=Clauses;!list_Empty(Scan);Scan=list_Cdr(Scan)) { Clause = (CLAUSE)list_Car(Scan); if (clause_IsFromInput(Clause)) { if (clause_GetFlag(Clause, CONCLAUSE)) ConClauses = list_Cons(Clause, ConClauses); else AxClauses = list_Cons(Clause, AxClauses); } else ProofClauses = list_Cons(Clause, ProofClauses); } ConClauses = list_NReverse(ConClauses); AxClauses = list_NReverse(AxClauses); ProofClauses = list_NReverse(ProofClauses); clause_FPrintCnfDFG(Output, FALSE, AxClauses, ConClauses, Flags, Precedence); fputs("\nlist_of_proof(SPASS).\n", Output); for (Scan=ProofClauses; !list_Empty(Scan); Scan=list_Cdr(Scan)) { clause_FPrintDFGStep(Output,list_Car(Scan),TRUE); } fputs("end_of_list.\n\n", Output); fputs("end_problem.\n\n", Output); misc_CloseFile(Output, name); fputs("\nDFG Proof printed to: ", stdout); puts(name); list_Delete(ConClauses); list_Delete(AxClauses); list_Delete(ProofClauses); memory_Free(name, sizeof(char)*(strlen(FilePrefix)+5)); }
TABLE table_Init(TABLE table, int opbound, int varbound, int termbound) /*************************************************************** INPUT: the table to recycle and bounds for the operator symbol, variable and term indices of the terms to be stored in the signature table (i. e. for every such term its top symbol index has to be in [1, opbound] and the term numbers of its arguments in [0, termbound] - or its variable index in [1, varbound] if it is a variable) RETURNS: a cleaned up signature table CAUTION: potentially frees the old table, therefore must be called inside of an assignment like: table = table_Init(table, ...) ***************************************************************/ { int opmax, varmax, termmax, i; TERMARRAY old; #ifdef CHECK if (opbound < 0) { misc_StartErrorReport(); misc_ErrorReport("\n In table_Init: negative opbound."); misc_FinishErrorReport(); } if (varbound < 0) { misc_StartErrorReport(); misc_ErrorReport("\n In table_Init: negative varbound."); misc_FinishErrorReport(); } if (termbound < 0) { misc_StartErrorReport(); misc_ErrorReport("\n In table_Init: negative termbound."); misc_FinishErrorReport(); } #endif opmax = table_GetOpbound(table) > opbound ? table_GetOpbound(table) : opbound; varmax = table_GetVarbound(table) > varbound ? table_GetVarbound(table) : varbound; termmax = table_GetTermbound(table) > termbound ? table_GetTermbound(table) : termbound; table_SetStampcounter(table, table_GetStampcounter(table) + 1); /* in case of stamp overflow or too small termarray nodes get a new table: */ if (table_GetStampcounter(table)<=0 || termbound>table_GetTermbound(table)) { table_Free(table); return table_Create(opmax, varmax, termmax); } /* if only the top layer of the tree is too small get a larger top layer: */ else if (opbound+varbound > table_GetOpbound(table)+table_GetVarbound(table)){ old = table_GetTermarray(table); table_SetTermarray(table, (TERMARRAY) memory_Calloc( opmax + varmax + 1, sizeof(struct termarray) ) + varmax); for (i = -table_GetVarbound(table); i <= table_GetOpbound(table); i++) table_SetChild(table_GetTermarray(table) + i, table_GetChild(old + i)); memory_Free( old - table_GetVarbound(table), (table_GetOpbound(table) + table_GetVarbound(table) + 1) * sizeof(struct termarray) ); table_SetOpbound(table, opmax); table_SetVarbound(table, varmax); return table; } else { /* move pointer to termarray's new middle: */ table_SetTermarray( table, table_GetTermarray(table) + table_GetOpbound(table) - opbound ); table_SetVarbound( table, table_GetOpbound(table) + table_GetVarbound(table) - opbound ); table_SetOpbound(table, opbound); return table; } }
static __inline__ void ia_StringFree(char* String) { memory_Free(String, sizeof(char)*(strlen(String)+1)); }