On Aug 2, 2010, at 12:46 PM, James Maxwell wrote:

>               // set the contents of the array
>               continuations = (float*)[aDecoder 
> decodeBytesForKey:@"continuations" returnedLength:&size];



>From the header file:

- (const uint8_t *)decodeBytesForKey:(NSString *)key returnedLength:(NSUInteger 
*)lengthp;      // returned bytes immutable, and they go away with the 
unarchiver, not the containing autorlease pool

And from the documentation:
Discussion
The returned value is a pointer to a temporary buffer owned by the receiver. 
The buffer goes away with the unarchiver, not the containing autorelease pool. 
You must copy the bytes into your own buffer if you need the data to persist 
beyond the life of the receiver.




So if your setContinuationSize: allocates memory, you should:

        const uint8_t *bytes = [aDecoder decodeBytesForKey:@"continuations" 
returnedLength:&size];
        NSAssert(size == [self continuationsSize] * sizeof(float), @"Bad size 
of bytes returned from decoding");
        memcpy(continuations, bytes, size);



Glenn Andreas                      gandr...@gandreas.com 
The most merciful thing in the world ... is the inability of the human mind to 
correlate all its contents - HPL

_______________________________________________

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 arch...@mail-archive.com

Reply via email to