--- joko/Uni/BSArch/04/bmp_fractal.c 2006/07/02 11:44:57 1.14 +++ joko/Uni/BSArch/04/bmp_fractal.c 2006/07/02 12:08:10 1.15 @@ -5,7 +5,7 @@ * Uebung 4.4 */ -// $Id: bmp_fractal.c,v 1.14 2006/07/02 11:44:57 joko Exp $ +// $Id: bmp_fractal.c,v 1.15 2006/07/02 12:08:10 joko Exp $ #include #include @@ -49,12 +49,12 @@ 0, NULL )) { - fprintf(stdout, "%s: %s\n", msg, lpMsgBuf); + fprintf(stderr, "%s: %s\n", msg, lpMsgBuf); LocalFree(lpMsgBuf); } else { - fprintf(stdout, "Error at FormatMesage: %d\n",err=GetLastError()); + fprintf(stderr, "Error at FormatMesage: %d\n",err=GetLastError()); } exit(err); } @@ -68,7 +68,7 @@ // open file handle fd = fopen(filename, "wb+"); if (NULL == fd) { - perror("open"); + perror("Error while opening file for writing"); exit(1); } @@ -77,7 +77,7 @@ // error checking if (-1 == len || len != sizeof(header)) { - perror("write"); + perror("Error while writing header to file"); exit(2); } @@ -86,7 +86,7 @@ for (i = 0; i < img_size; i++) { len = fwrite("\0\0\0", 1, 3, fd); if (-1 == len || len != 3) { - perror("write"); + perror("Error while writing data to file"); exit(4); } } @@ -315,7 +315,7 @@ // allocate memory for one worker's arguments if ((worker_args = malloc(sizeof(worker_args[0]))) == NULL) - perror("malloc"), exit(1); + perror("Error while allocating memory for worker arguments via malloc"), exit(1); // assign worker's arguments worker_args[0].start_row = worker_startrow; @@ -348,11 +348,11 @@ // allocate memory for table of all worker handles if ((worker_handles = malloc(workers * sizeof(worker_handles[0]))) == NULL) - perror("malloc"), exit(1); + perror("Error while allocating memory for worker handles via malloc"), exit(1); // allocate memory for table of all worker arguments if ((worker_args = malloc(workers * sizeof(worker_args[0]))) == NULL) - perror("malloc"), exit(1); + perror("Error while allocating memory for worker arguments via malloc"), exit(1); // calculate bitmap segment length for workers @@ -431,7 +431,7 @@ if (VERBOSE) fprintf(stdout, "waiting for workers to finish...\n"); if (WaitForMultipleObjects(workers, worker_handles, TRUE, INFINITE) == WAIT_FAILED) - perror("WaitForMultipleObjects"); + printErrorAndExit("Error at WaitForMultipleObjects", GetLastError()); // debugging: just run single thread //if (WaitForSingleObject(worker_handles[0], INFINITE) == WAIT_FAILED)