void dbClose(int did) { int table, column; dbTable_t *pTable; /* * Before doing anything, delete all the contents of the database */ dbZero(did); /* * Now delete the tables */ for (table = 0; table < dbMaxTables; table++) { pTable = dbListTables[table]; if (pTable != NULL) { /* * Delete the table schema */ if (pTable->nColumns) { for (column = 0; column < pTable->nColumns; column++) { bfreeSafe(B_L, pTable->columnNames[column]); } bfreeSafe(B_L, pTable->columnNames); bfreeSafe(B_L, pTable->columnTypes); } /* * Delete the table name */ bfreeSafe(B_L, pTable->name); /* * Free the table */ bfreeSafe(B_L, pTable); hFree((void ***) &dbListTables, table); } } if (dbListTables) { bfree(B_L, dbListTables); } /* * Set the global table list to a safe value */ dbListTables = NULL; dbMaxTables = 0; }
int umRestore(char_t *filename) { if (filename && *filename) { if (saveFilename != NULL) { bfree(B_L, saveFilename); } saveFilename = bstrdup(B_L, filename); } a_assert(saveFilename && *saveFilename); trace(3, T("UM: Loading User Configuration from file <%s>\n"), saveFilename); /* * First empty the database, otherwise we wind up with duplicates! */ dbZero(didUM); return dbLoad(didUM, saveFilename, 0); }