Re: Puzzling Analyzer output
Re: Puzzling Analyzer output
- Subject: Re: Puzzling Analyzer output
- From: Ralf Schuchardt <email@hidden>
- Date: Thu, 1 Apr 2010 15:03:17 +0200
Am 01.04.2010 um 11:56 schrieb Matt Gough:
> When running the analyzer on my app, I get the following warning:
>
> warning: Object with +0 retain counts returned to caller where a +1 (owning) retain count is expected
> return data;
> ^
>
> in the following method
>
> - (NSData*) dataNoCopyForColumnIndex:(int)columnIdx {
>
> if (sqlite3_column_type(statement.statement, columnIdx) == SQLITE_NULL || (columnIdx < 0)) {
> return nil;
> }
>
> int dataSize = sqlite3_column_bytes(statement.statement, columnIdx);
>
> NSData *data = [NSData dataWithBytesNoCopy:(void *)sqlite3_column_blob(statement.statement, columnIdx) length:(NSUInteger)dataSize freeWhenDone:NO];
>
> return data;
> }
>
>
> I can't see anything wrong with the code, and its a common enough pattern to return autoreleased objects.
>
> Is this just a false positive, or is there something obscure I am overlooking related to the NoCopy version of dataWithBytes?
The analyzer is confused by the word "copy" in your method name "dataNoCopyForColumnIndex:". When you change this to another word like "duplicate" you should no longer get the warning.
Ralf
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden