X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2Fwin32%2FWorkQueue.c;h=b676072c967a50f26d2539968152bf958a7b3507;hb=c004ec62b41aa2137b5b5e298ca562609b0de92e;hp=85a23608bee35de5ff9dc091c95070e3827f182f;hpb=0065d5ab628975892cea1ec7303f968c3338cbe1;p=ghc-hetmet.git diff --git a/rts/win32/WorkQueue.c b/rts/win32/WorkQueue.c index 85a2360..b676072 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,8 +80,9 @@ FreeWorkQueue ( WorkQueue* pq ) CloseHandle(pq->workAvailable); } if ( pq->roomAvailable ) { - CloseHandle(pq->workAvailable); + CloseHandle(pq->roomAvailable); } + DeleteCriticalSection(&pq->queueLock); free(pq); return; }