X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=rts%2Fwin32%2FWorkQueue.c;h=a0b06f36386772eb931c4402294ee0995c7a7bc3;hb=c76c69c5b62f1ca4fa52d75b0dfbd37b7eddbb09;hp=85a23608bee35de5ff9dc091c95070e3827f182f;hpb=0065d5ab628975892cea1ec7303f968c3338cbe1;p=ghc-hetmet.git diff --git a/rts/win32/WorkQueue.c b/rts/win32/WorkQueue.c index 85a2360..a0b06f3 100644 --- a/rts/win32/WorkQueue.c +++ b/rts/win32/WorkQueue.c @@ -45,8 +45,7 @@ NewWorkQueue() return wq; } - wq->head = 0; - wq->tail = 0; + memset(wq, 0, sizeof *wq); InitializeCriticalSection(&wq->queueLock); wq->workAvailable = newSemaphore(0, WORKQUEUE_SIZE); @@ -65,6 +64,15 @@ NewWorkQueue() void FreeWorkQueue ( WorkQueue* pq ) { + int i; + + /* Free any remaining work items. */ + for (i = 0; i < WORKQUEUE_SIZE; i++) { + if (pq->items[i] != NULL) { + free(pq->items[i]); + } + } + /* Close the semaphores; any threads blocked waiting * on either will as a result be woken up. */ @@ -72,7 +80,7 @@ FreeWorkQueue ( WorkQueue* pq ) CloseHandle(pq->workAvailable); } if ( pq->roomAvailable ) { - CloseHandle(pq->workAvailable); + CloseHandle(pq->roomAvailable); } free(pq); return;