diff --git a/ChangeLog b/ChangeLog index 85052c7a3..53ee335a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2011-02-11 Richard Frith-Macdonald + + * Source/NSUserDefaults.m: + * Source/NSArray.m: + * Source/NSString.m: + * Source/NSPointerArray.m: + * Tools/AGSParser.m: + Tweaks to try to avoid clang analyser warnings. + * Source/NSPropertyList.m: + Revert last change. + 2011-02-11 Stefan Bidigaray * Source/NSDateFormatter.m: Avoid multiple memory copy operations. diff --git a/Source/NSArray.m b/Source/NSArray.m index a736bc124..979876ff0 100644 --- a/Source/NSArray.m +++ b/Source/NSArray.m @@ -1093,11 +1093,11 @@ compare(id elem1, id elem2, void* context) { NSMutableArray *sortedArray; - sortedArray = [[NSMutableArrayClass allocWithZone: - NSDefaultMallocZone()] initWithArray: self copyItems: NO]; + sortedArray = [[[NSMutableArrayClass allocWithZone: + NSDefaultMallocZone()] initWithArray: self copyItems: NO] autorelease]; [sortedArray sortUsingFunction: comparator context: context]; - return AUTORELEASE([sortedArray makeImmutableCopyOnFail: NO]); + return [sortedArray makeImmutableCopyOnFail: NO]; } /** @@ -1107,8 +1107,9 @@ compare(id elem1, id elem2, void* context) - (NSString*) componentsJoinedByString: (NSString*)separator { unsigned int c = [self count]; - NSMutableString *s = [[NSMutableString alloc] initWithCapacity: c]; + NSMutableString *s; + s = [[[NSMutableString alloc] initWithCapacity: c] autorelease]; if (c > 0) { unsigned l = [separator length]; @@ -1124,7 +1125,7 @@ compare(id elem1, id elem2, void* context) [s appendString: [[self objectAtIndex: i] description]]; } } - return AUTORELEASE([s makeImmutableCopyOnFail: NO]); + return [s makeImmutableCopyOnFail: NO]; } /** @@ -1135,7 +1136,7 @@ compare(id elem1, id elem2, void* context) - (NSArray*) pathsMatchingExtensions: (NSArray*)extensions { unsigned i, c = [self count]; - NSMutableArray *a = [[NSMutableArray alloc] initWithCapacity: 1]; + NSMutableArray *a = [[[NSMutableArray alloc] initWithCapacity: 1] autorelease]; Class cls = [NSString class]; IMP get = [self methodForSelector: oaiSel]; IMP add = [a methodForSelector: addSel]; @@ -1152,7 +1153,7 @@ compare(id elem1, id elem2, void* context) } } } - return AUTORELEASE([a makeImmutableCopyOnFail: NO]); + return [a makeImmutableCopyOnFail: NO]; } /** diff --git a/Source/NSPointerArray.m b/Source/NSPointerArray.m index c9359502a..955cd5256 100644 --- a/Source/NSPointerArray.m +++ b/Source/NSPointerArray.m @@ -261,8 +261,7 @@ static Class concreteClass = Nil; [a addObject: (id)_contents[i]]; } } - [a makeImmutableCopyOnFail: NO]; - return a; + return [a makeImmutableCopyOnFail: NO]; } } diff --git a/Source/NSString.m b/Source/NSString.m index 016b4dd3b..8c5fe0cc9 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -1781,13 +1781,13 @@ handle_printf_atsign (FILE *stream, { id copy; - copy = [[GSMutableStringClass allocWithZone: NSDefaultMallocZone()] - initWithString: self]; + copy = [[[GSMutableStringClass allocWithZone: NSDefaultMallocZone()] + initWithString: self] autorelease]; [copy replaceOccurrencesOfString: replace withString: by options: opts range: searchRange]; - return [[copy makeImmutableCopyOnFail: NO] autorelease]; + return [copy makeImmutableCopyOnFail: NO]; } - (NSString*) stringByReplacingOccurrencesOfString: (NSString*)replace @@ -1809,10 +1809,10 @@ handle_printf_atsign (FILE *stream, { id copy; - copy = [[GSMutableStringClass allocWithZone: NSDefaultMallocZone()] - initWithString: self]; + copy = [[[GSMutableStringClass allocWithZone: NSDefaultMallocZone()] + initWithString: self] autorelease]; [copy replaceCharactersInRange: aRange withString: by]; - return [[copy makeImmutableCopyOnFail: NO] autorelease]; + return [copy makeImmutableCopyOnFail: NO]; } /** diff --git a/Source/NSUserDefaults.m b/Source/NSUserDefaults.m index a513d3492..1adcd8f68 100644 --- a/Source/NSUserDefaults.m +++ b/Source/NSUserDefaults.m @@ -1908,7 +1908,7 @@ NSLog(@"Creating empty user defaults database"); [_lock lock]; NS_DURING { - if (_dictionaryRep == nil) + if (nil == _dictionaryRep) { NSEnumerator *enumerator; NSMutableDictionary *dictRep; @@ -1925,8 +1925,8 @@ NSLog(@"Creating empty user defaults database"); enumerator = [_searchList reverseObjectEnumerator]; nImp = [enumerator methodForSelector: nextObjectSel]; - dictRep = [NSMutableDictionaryClass allocWithZone: NSDefaultMallocZone()]; - dictRep = [dictRep initWithCapacity: 512]; + dictRep = [NSMutableDictionaryClass alloc]; + dictRep = [[dictRep initWithCapacity: 512] autorelease]; addImp = [dictRep methodForSelector: addSel]; while ((obj = (*nImp)(enumerator, nextObjectSel)) != nil) @@ -1939,7 +1939,10 @@ NSLog(@"Creating empty user defaults database"); } _dictionaryRep = [dictRep makeImmutableCopyOnFail: NO]; } - rep = [[_dictionaryRep retain] autorelease]; + else + { + rep = [[_dictionaryRep retain] autorelease]; + } [_lock unlock]; } NS_HANDLER diff --git a/Tools/AGSParser.m b/Tools/AGSParser.m index bbb99201a..302c1db9a 100644 --- a/Tools/AGSParser.m +++ b/Tools/AGSParser.m @@ -2189,6 +2189,7 @@ fail: */ [self skipUnit]; DESTROY(comment); + RELEASE(arp); return [NSMutableDictionary dictionary]; } else