On Jun 6, 2008, at 7:05 PM, Ricky Sharp wrote:


On Jun 6, 2008, at 6:42 PM, Bill Bumgarner wrote:


Sorry -- let me clarify. If the <data> was either released in a different thread or if <data> were explicitly released in the above code, then you would see the same crash. I didn't mean to imply that <data> would be released under non-GC without some explicit action being taken.

Under GC, the situation isn't quite so clear.


That makes perfect sense. Sorry that I glossed over the 'other thread' bit.


What about using the data pointer directly in the loop? Would this prevent the GC thread from freeing that memory early? This sends a message to the data object at each iteration, so not as optimal as pointer arithmetic I suppose...

        NSData* data = <get it from somewhere>;
        NSUInteger count = [data length];
        for (NSUInteger i = 0; i < count; i++)
                [data getBytes:&something range:NSMakeRange(i, 1)];

Cheers,
George
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to