getting rid of several potential memory leaks and incorrect releases
This commit is contained in:
@@ -53,7 +53,7 @@
|
|||||||
if(self) {
|
if(self) {
|
||||||
wm = wm_;
|
wm = wm_;
|
||||||
|
|
||||||
device = device_;
|
device = [device_ retain];
|
||||||
controlChannel = nil;
|
controlChannel = nil;
|
||||||
interruptChannel = nil;
|
interruptChannel = nil;
|
||||||
|
|
||||||
@@ -161,9 +161,6 @@
|
|||||||
|
|
||||||
// forward event data to C struct
|
// forward event data to C struct
|
||||||
memcpy(wm->event_buf, data, sizeof(wm->event_buf));
|
memcpy(wm->event_buf, data, sizeof(wm->event_buf));
|
||||||
|
|
||||||
// clear local buffer
|
|
||||||
[firstData release];
|
|
||||||
}
|
}
|
||||||
[receivedDataLock unlock];
|
[receivedDataLock unlock];
|
||||||
|
|
||||||
@@ -175,11 +172,11 @@
|
|||||||
NSRunLoop *theRL = [NSRunLoop currentRunLoop];
|
NSRunLoop *theRL = [NSRunLoop currentRunLoop];
|
||||||
while (true) {
|
while (true) {
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // This is used for fast release of NSDate, otherwise it leaks
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // This is used for fast release of NSDate, otherwise it leaks
|
||||||
|
|
||||||
if(![theRL runMode:NSDefaultRunLoopMode beforeDate:timeoutDate]) {
|
if(![theRL runMode:NSDefaultRunLoopMode beforeDate:timeoutDate]) {
|
||||||
WIIUSE_ERROR("Could not start run loop while waiting for read [id %i].", wm->unid);
|
WIIUSE_ERROR("Could not start run loop while waiting for read [id %i].", wm->unid);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
[pool drain];
|
||||||
|
|
||||||
[receivedDataLock lock];
|
[receivedDataLock lock];
|
||||||
NSUInteger count = [receivedData count];
|
NSUInteger count = [receivedData count];
|
||||||
@@ -193,8 +190,6 @@
|
|||||||
// timeout
|
// timeout
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
[pool drain];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,9 +266,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// copy the data into the buffer
|
// copy the data into the buffer
|
||||||
|
NSData* newData = [[NSData alloc] initWithBytes:data length:length];
|
||||||
[receivedDataLock lock];
|
[receivedDataLock lock];
|
||||||
[receivedData addObject: [[NSData alloc] initWithBytes:data length:length]];
|
[receivedData addObject: newData];
|
||||||
[receivedDataLock unlock];
|
[receivedDataLock unlock];
|
||||||
|
[newData release];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -131,7 +131,6 @@
|
|||||||
|
|
||||||
// save the device in the wiimote structure
|
// save the device in the wiimote structure
|
||||||
wiimotes[i]->objc_wm = (void*) [[WiiuseWiimote alloc] initWithPtr:wiimotes[i] device: device];
|
wiimotes[i]->objc_wm = (void*) [[WiiuseWiimote alloc] initWithPtr:wiimotes[i] device: device];
|
||||||
[device retain]; // must retain it for later access through its ref
|
|
||||||
|
|
||||||
// mark as found
|
// mark as found
|
||||||
WIIMOTE_ENABLE_STATE(wiimotes[i], WIIMOTE_STATE_DEV_FOUND);
|
WIIMOTE_ENABLE_STATE(wiimotes[i], WIIMOTE_STATE_DEV_FOUND);
|
||||||
|
|||||||
Reference in New Issue
Block a user