In a Cocoa app targeting Leopard, I am getting a malloc error when using the
NSData method

- (void)getBytes:(void *)buffer

My function is as follows:

-(void)getDataSz:(void*)data ofSize:(NSUInteger)sz
{
   NSData *theData = [input readDataOfLength:sz];
   [theData getBytes:data];     // <-- no error when commented out
}

This function is actually in a subtask and
input
is an NSFileHandle.

Input is reading data (from the main task) correctly with no error.
However,

[theData getBytes:data];

generates the following error (most of the time):

malloc: *** free() called with 0x9aadca0 with refcount 0
malloc: *** auto malloc[3230]: agc error for object 0x9aadca0: Deallocating
a non-block

In normal operation, getDataSz takes in a buffer allocated by an STL vector
in the following call:

[mySubtaskServer getDataSz:&my_vec[0] ofSize:dataSize];

If (just for testing), I replace the argument, data, with a local malloc
buffer (in getDataSz) and free it before exiting, then I do not see this
error.  

FWIW, I also do not see this error in an earlier call in which the amount of
data read is less than a block (4096 bytes).

The Build options have
Call C++ Default Ctors/Dtors in Objective-C
set to YES
and garbage-collection is Supported.

Compiler is gcc 4.2.

Is there something else I should be doing here?
Thanks.

-- 
Mike McLaughlin

_______________________________________________

Cocoa-dev mailing list ([email protected])

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