adium 3110:3d0a53def683: Fix a few memory leaks introduced by Au...

commits at adium.im commits at adium.im
Fri Feb 5 01:38:02 UTC 2010


details:	http://hg.adium.im/adium/rev/3d0a53def683
revision:	3110:3d0a53def683
author:		Stephen Holt <sholt at adium.im>
date:		Thu Feb 04 20:37:55 2010 -0500

Fix a few memory leaks introduced by AutoHyperlinks changes.

diffs (60 lines):

diff -r 01c07754dedf -r 3d0a53def683 Frameworks/AutoHyperlinks Framework/Source/AHHyperlinkScanner.m
--- a/Frameworks/AutoHyperlinks Framework/Source/AHHyperlinkScanner.m	Thu Feb 04 19:32:21 2010 -0500
+++ b/Frameworks/AutoHyperlinks Framework/Source/AHHyperlinkScanner.m	Thu Feb 04 20:37:55 2010 -0500
@@ -387,25 +387,25 @@
 	unsigned long _scanLocationCache = self.scanLocation;
 	
 	if(m_scanAttrString) {
-		_linkifiedString = [m_scanAttrString mutableCopy];
+		_linkifiedString = [[m_scanAttrString mutableCopy] autorelease];
 	} else {
-		_linkifiedString = [[NSMutableAttributedString alloc] initWithString:m_scanString];
+		_linkifiedString = [[[NSMutableAttributedString alloc] initWithString:m_scanString] autorelease];
 	}
 
 	//for each SHMarkedHyperlink, add the proper URL to the proper range in the string.
 	for(markedLink in self) {
 		NSURL *markedLinkURL;
 		_didFindLinks = YES;
-		if((markedLinkURL = [markedLink URL])) {
+		if((markedLinkURL = markedLink.URL)) {
 			[_linkifiedString addAttribute:NSLinkAttributeName
 									value:markedLinkURL
-									range:[markedLink range]];
+									range:markedLink.range];
 		}
 	}
 			
 	self.scanLocation = _scanLocationCache;
 	return _didFindLinks? _linkifiedString :
-						  m_scanAttrString ? m_scanAttrString : [[NSMutableAttributedString alloc] initWithString:m_scanString];
+						  m_scanAttrString ? [[m_scanAttrString retain] autorelease] : [[[NSMutableAttributedString alloc] initWithString:m_scanString] autorelease];
 }
 
 -(NSAttributedString *)linkifiedString
@@ -414,10 +414,10 @@
 		NSAttributedString *newLinkifiedString = [self _createLinkifiedString];
 		// compare the old object to nil, and swap in the new value if they match.
 		// if the old object (m_linkifiedString) already has a value, release the duplicated new object
-		if(!OSAtomicCompareAndSwapPtrBarrier(nil, newLinkifiedString, (void *)&m_linkifiedString))
-			[newLinkifiedString release];
+		if(OSAtomicCompareAndSwapPtrBarrier(nil, newLinkifiedString, (void *)&m_linkifiedString))
+			[m_linkifiedString retain];
 	}
-	return [[[NSAttributedString alloc] initWithAttributedString:m_linkifiedString] autorelease];
+	return m_linkifiedString;
 }
 
 #pragma mark NSFastEnumeration
diff -r 01c07754dedf -r 3d0a53def683 Frameworks/AutoHyperlinks Framework/Source/AHMarkedHyperlink.m
--- a/Frameworks/AutoHyperlinks Framework/Source/AHMarkedHyperlink.m	Thu Feb 04 19:32:21 2010 -0500
+++ b/Frameworks/AutoHyperlinks Framework/Source/AHMarkedHyperlink.m	Thu Feb 04 20:37:55 2010 -0500
@@ -98,7 +98,7 @@
 																	 NULL,
 																	 kCFStringEncodingUTF8); // kCFStringEncodingISOLatin1 );
 
-	self.URL = [[NSURL alloc] initWithString:linkString];
+	self.URL = [NSURL URLWithString:linkString];
 
 	[linkString release];
 	if(preString) [preString release];




More information about the commits mailing list