--- joko/Uni/BSArch/04/bmp_fractal.c 2006/07/01 20:31:31 1.7 +++ joko/Uni/BSArch/04/bmp_fractal.c 2006/07/01 22:10:42 1.8 @@ -5,7 +5,7 @@ * Uebung 4.4 */ -// $Id: bmp_fractal.c,v 1.7 2006/07/01 20:31:31 joko Exp $ +// $Id: bmp_fractal.c,v 1.8 2006/07/01 22:10:42 joko Exp $ #include #include @@ -163,7 +163,7 @@ unsigned char *pDataBitmap, *pDataBitmapCurrent; // workers - int workers = 10; + int workers = 5; int worker_index, worker_rows, worker_startrow; HANDLE *worker_handles; //struct WorkerArguments *worker_args; @@ -217,13 +217,18 @@ if ((worker_handles = malloc(workers * sizeof worker_handles[0])) == NULL) perror("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); - */ + // allocate memory for table of all worker arguments - worker_args = (PWORKERARGS) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, workers * sizeof(WORKERARGS)); + /* + worker_args = (PWORKERARGS) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY | HEAP_NO_SERIALIZE, workers * sizeof(WORKERARGS)); + + if (worker_args == NULL) { + printErrorAndExit("Failed to allocate on heap", GetLastError()); + } + */ // calculate segments of bitmap for worker threads/processes and start them worker_rows = YSIZE / workers; @@ -289,4 +294,13 @@ printErrorAndExit("Error at CloseHandle", err); } + /* + if (HeapFree(GetProcessHeap(), HEAP_ZERO_MEMORY | HEAP_NO_SERIALIZE, worker_args) != TRUE) { + printErrorAndExit("Call to HeapFree has failed", GetLastError()); + } + */ + + + return 0; + }