Permalink
Browse files

fix for test15 leaks, GH issue #4

  • Loading branch information...
1 parent 86738d2 commit a241ad079ce2fedae18287bf3f698065b0676e07 @xk committed Mar 21, 2012
Showing with 4 additions and 14 deletions.
  1. +2 −3 src/queues_a_gogo.cc
  2. +2 −11 src/threads_a_gogo.cc
View
5 src/queues_a_gogo.cc
@@ -80,8 +80,7 @@ static typeQueueItem* queue_pull (typeQueue* queue) {
static typeQueueItem* nuItem (int itemType, void* item) {
- typeQueueItem* qitem= NULL;
- if (freeItemsQueue && freeItemsQueue->first) qitem= queue_pull(freeItemsQueue);
+ typeQueueItem* qitem= qitem= queue_pull(freeItemsQueue);
if (!qitem) {
qitem= (typeQueueItem*) calloc(1, sizeof(typeQueueItem));
}
@@ -94,7 +93,7 @@ static typeQueueItem* nuItem (int itemType, void* item) {
else if (itemType == kItemTypePointer) {
qitem->asPtr= item;
}
-
+
return qitem;
}
View
13 src/threads_a_gogo.cc
@@ -106,7 +106,6 @@ cat ../../../src/thread_nextTick.js | ./minify kThread_nextTick_js > ../../../sr
static typeQueueItem* nuJobQueueItem (void) {
typeQueueItem* qitem= queue_pull(freeJobsQueue);
- //freeJobsQueue && freeJobsQueue->first && (qitem= queue_pull(freeJobsQueue));
if (!qitem) {
qitem= nuItem(kItemTypePointer, calloc(1, sizeof(typeJob)));
}
@@ -305,6 +304,7 @@ static void eventLoop (typeThread* thread) {
}
free(job->typeEvent.argumentos);
+ queue_push(qitem, freeJobsQueue);
dispatchEvents->CallAsFunction(global, 2, args);
}
}
@@ -412,15 +412,6 @@ static void Callback (EV_P_ ev_async *watcher, int revents) {
}
queue_push(qitem, freeJobsQueue);
- /*
- if (freeJobsQueue) {
- queue_push(qitem, freeJobsQueue);
- }
- else {
- free(job);
- destroyItem(qitem);
- }
- */
if (onError.HasCaught()) {
if (thread->outQueue.first) {
@@ -667,7 +658,7 @@ static Handle<Value> Create (const Arguments &args) {
typeThread* thread;
typeQueueItem* qitem= NULL;
- freeThreadsQueue && freeThreadsQueue->first && (qitem= queue_pull(freeThreadsQueue));
+ qitem= queue_pull(freeThreadsQueue);
if (qitem) {
thread= (typeThread*) qitem->asPtr;
destroyItem(qitem);

0 comments on commit a241ad0

Please sign in to comment.