int freeDynamicScreen(EdgeList **dynamicScreen){ char debugStr[256]; if(dynamicScreen == NULL){ sprintf_s(debugStr,"Error: freeDynamicScreen dynamicScreen=NULL parameter passed\n");printf(debugStr); return 1; } //TODO: freeing memory can cause issue check later for(int y=0;y<YRES;y++){ if(dynamicScreen[y] !=NULL){ freeEdgeList(dynamicScreen[y]); } } return 0; }
int readFile(char* path) { FILE* fileHandle; int graphSize, n, i; fileHandle = fopen(path, "r"); if (fileHandle == NULL) { perror("Error opening file."); return -1; } fscanf(fileHandle, "%d", &n); accusation accArray[MAXEDGES]; char* names[n]; edgeList accusations = {0, 0, accArray, names}; for (i = 0; i < n; ++i) readAccusation(fileHandle, &accusations); graphSize = accusations.nameIndex; node graph[graphSize]; buildGraph(graph, &accusations); int knights, knaves; knights = knaves = 0; partition(graph, graphSize, &knights, &knaves); if (knights > knaves) printf("%d %d\n", knights, knaves); else printf("%d %d\n", knaves, knights); freeEdgeList(&accusations); freeNameList(&accusations); freeGraph(graph, graphSize); return 0; }