Jeff Laing avatar Jeff Laing committed 63b3cf3

Change the way we allocate memory for the buffer in copyRemoteFile:toLocalFile:
Accessing the NSMutableData's innards seemed to be causing weird log messages in the debugger.

Comments (0)

Files changed (1)


 				if (!out) {
 					[self setLastError:@"Can't open output file"];
 				} else {
-					// copy all content across 10K at a time...
+					// copy all content across 10K at a time...  use
+					// malloc for the buffer rather than NSData because I've noticed
+					// strange problems in the debugger
 					const uint32_t bufsz = 10240;
-					NSMutableData *buff = [[NSMutableData alloc] initWithLength:bufsz];
+					char *buff = malloc(bufsz);
 					while (1) {
-						uint32_t n = [in readN:bufsz bytes:[buff mutableBytes]];
+						uint32_t n = [in readN:bufsz bytes:buff];
 						if (n==0) break;
-						[out writeData:[NSData dataWithBytesNoCopy:[buff mutableBytes] length:n freeWhenDone:NO]];
+						NSData *b2 = [[NSData alloc]
+									  initWithBytesNoCopy:buff length:n freeWhenDone:NO];
+						[out writeData:b2];
+						[b2 release];
-					[buff release];
+					free(buff);
 					[out closeFile];
 					[self clearLastError];
 					result = YES;
 		// we can access device values once we are connected - at 5.0.1, the behaviour
         // seemed to change slightly, and we need a session established as well, so we
         // use our regular method rather than directly calling AMDeviceCopyValue()
+        //
+        // Could there be a UserAssignedDeviceName ?
+        //
 		_deviceName = [[self deviceValueForKey:@"DeviceName"] retain];
         _udid = [[self deviceValueForKey:@"UniqueDeviceID"] retain];
 void notify_callback(struct am_device_notification_callback_info *info, void* arg)
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 	[(MobileDeviceAccess*)arg Notify:info];
+    [pool drain];
 - (void)applicationWillTerminate:(NSNotification*)notification
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.