/* ============================================================================= * manager_free * ============================================================================= */ void manager_free (manager_t* managerPtr) { tableFree(managerPtr->carTablePtr); tableFree(managerPtr->roomTablePtr); tableFree(managerPtr->flightTablePtr); tableFree(managerPtr->customerTablePtr); }
static LRESULT CALLBACK tableWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { struct table *t; LRESULT lResult; t = (struct table *) GetWindowLongPtrW(hwnd, GWLP_USERDATA); if (t == NULL) { // we have to do things this way because creating the header control will fail mysteriously if we create it first thing // (which is fine; we can get the parent hInstance this way too) // we use WM_CREATE because we have to use WM_DESTROY to destroy the header; we can't do it in WM_NCDESTROY because Windows will have destroyed it for us by then, and let's match message pairs to be safe if (uMsg == WM_CREATE) { CREATESTRUCTW *cs = (CREATESTRUCTW *) lParam; t = (struct table *) tableAlloc(sizeof (struct table), "error allocating internal Table data structure"); t->hwnd = hwnd; makeHeader(t, cs->hInstance); t->selectedRow = -1; t->selectedColumn = -1; initDummyTableStuff(t); SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR) t); } // even if we did the above, fall through return DefWindowProcW(hwnd, uMsg, wParam, lParam); } if (uMsg == WM_DESTROY) { printf("destroy\n"); // TODO free appropriate (after figuring this part out) components of t // TODO send EVENT_OBJECT_DESTROY events to accessibility listeners (when appropriate); see the note on proxy objects as well destroyHeader(t); tableFree(t, "error allocating internal Table data structure"); return DefWindowProcW(hwnd, uMsg, wParam, lParam); } if (runHandlers(handlers, t, uMsg, wParam, lParam, &lResult)) return lResult; return DefWindowProcW(hwnd, uMsg, wParam, lParam); }
int dfaExport(DFA *a, char *filename, int num, char *vars[], char orders[]) { Table *table = tableInit(); int i; FILE *file; if (filename) { if ((file = fopen(filename, "w")) == 0) return 0; } else file = stdout; /* remove all marks in a->bddm */ bdd_prepare_apply1(a->bddm); /* build table of tuples (idx,lo,hi) */ for (i = 0; i < a->ns; i++) export(a->bddm, a->q[i], table); /* renumber lo/hi pointers to new table ordering */ for (i = 0; i < table->noelems; i++) { if (table->elms[i].idx != -1) { table->elms[i].lo = bdd_mark(a->bddm, table->elms[i].lo) - 1; table->elms[i].hi = bdd_mark(a->bddm, table->elms[i].hi) - 1; } } /* write to file */ fprintf(file, "MONA DFA\n" "number of variables: %u\n" "variables:", num); for (i = 0; i < num; i++) fprintf(file, " %s", vars[i]); fprintf(file, "\n" "orders:"); for (i = 0; i < num; i++) fprintf(file, " %u", (unsigned) orders[i]); fprintf(file, "\n" "states: %u\n" "initial: %u\n" "bdd nodes: %u\n" "final:", a->ns, a->s, table->noelems); for (i = 0; i < a->ns; i++) fprintf(file, " %d", a->f[i]); fprintf(file, "\nbehaviour:"); for (i = 0; i < a->ns; i++) fprintf(file, " %u", bdd_mark(a->bddm, a->q[i]) - 1); fprintf(file, "\nbdd:\n"); for (i = 0; i < table->noelems; i++) fprintf(file, " %i %u %u\n", table->elms[i].idx, table->elms[i].lo, table->elms[i].hi); fprintf(file, "end\n"); tableFree(table); if (filename) fclose(file); return 1; }