Re: Size limit of NSData or NSFileHandle?
Re: Size limit of NSData or NSFileHandle?
- Subject: Re: Size limit of NSData or NSFileHandle?
- From: Ondra Cada <email@hidden>
- Date: Mon, 10 Apr 2006 16:33:29 +0200
Greg,
you are right of course, but for one small glitch:
On 10.4.2006, at 16:21, Greg Herlihy wrote:
NSData * data = [fh availableData];
len = [data length];
printf("data len: %d offset: %lld\n", len, [fh offsetInFile]);
// release the data before reading more
// or the consequences will be quite unpleasant
[data release];
availableData happens to return an autorelease object (just like more
or less anything but for alloc/init, new, and mutable/copy). Thus,
the proper pattern is (something like)
for (;;) {
NSAutoreleasePool *pool=[[NSAutoreleasePool alloc] init];
NSData *data=[fh availableData];
if (![data length]) break;
...
[pool release];
}
Depending on the task it might be better to release the pool not each
time, but every N times, yadda yadda yadda :)
---
Ondra Čada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden