adium 2568:e0525a651346: Don't leak the color arrays for group c...

commits at adium.im commits at adium.im
Thu Aug 6 04:13:30 UTC 2009


details:	http://hg.adium.im/adium/rev/e0525a651346
revision:	2568:e0525a651346
author:		Zachary West <zacw at adium.im>
date:		Thu Aug 06 00:16:29 2009 -0400

Don't leak the color arrays for group chats.

diffs (26 lines):

diff -r e9d5997a22bf -r e0525a651346 Frameworks/AIUtilities Framework/Source/AIColorAdditions.m
--- a/Frameworks/AIUtilities Framework/Source/AIColorAdditions.m	Mon Jul 27 20:36:45 2009 -0500
+++ b/Frameworks/AIUtilities Framework/Source/AIColorAdditions.m	Thu Aug 06 00:16:29 2009 -0400
@@ -21,6 +21,7 @@
 #import "AIStringAdditions.h"
 #import <string.h>
 
+static NSArray *defaultValidColors = nil;
 #define VALID_COLORS_ARRAY [[NSArray alloc] initWithObjects:@"aqua", @"aquamarine", @"blue", @"blueviolet", @"brown", @"burlywood", @"cadetblue", @"chartreuse", @"chocolate", @"coral", @"cornflowerblue", @"crimson", @"cyan", @"darkblue", @"darkcyan", @"darkgoldenrod", @"darkgreen", @"darkgrey", @"darkkhaki", @"darkmagenta", @"darkolivegreen", @"darkorange", @"darkorchid", @"darkred", @"darksalmon", @"darkseagreen", @"darkslateblue", @"darkslategrey", @"darkturquoise", @"darkviolet", @"deeppink", @"deepskyblue", @"dimgrey", @"dodgerblue", @"firebrick", @"forestgreen", @"fuchsia", @"gold", @"goldenrod", @"green", @"greenyellow", @"grey", @"hotpink", @"indianred", @"indigo", @"lawngreen", @"lightblue", @"lightcoral", @"lightgreen", @"lightgrey", @"lightpink", @"lightsalmon", @"lightseagreen", @"lightskyblue", @"lightslategrey", @"lightsteelblue", @"lime", @"limegreen", @"magenta", @"maroon", @"mediumaquamarine", @"mediumblue", @"mediumorchid", @"mediumpurple", @"mediumseagreen!
 ", @"mediumslateblue", @"mediumspringgreen", @"mediumturquoise", @"mediumvioletred", @"midnightblue", @"navy", @"olive", @"olivedrab", @"orange", @"orangered", @"orchid", @"palegreen", @"paleturquoise", @"palevioletred", @"peru", @"pink", @"plum", @"powderblue", @"purple", @"red", @"rosybrown", @"royalblue", @"saddlebrown", @"salmon", @"sandybrown", @"seagreen", @"sienna", @"silver", @"skyblue", @"slateblue", @"slategrey", @"springgreen", @"steelblue", @"tan", @"teal", @"thistle", @"tomato", @"turquoise", @"violet", @"yellowgreen", nil]
 
 static const float ONE_THIRD = 1.0/3.0;
@@ -612,8 +613,12 @@
 {
 	NSArray *validColorsArray = validColors;
 
-	if (!validColorsArray || [validColorsArray count] == 0)
-		validColorsArray = VALID_COLORS_ARRAY;
+	if (!validColorsArray || [validColorsArray count] == 0) {
+		if (!defaultValidColors) {
+			defaultValidColors = VALID_COLORS_ARRAY;
+		}
+		validColorsArray = defaultValidColors;
+	}
 
 	return [validColorsArray objectAtIndex:([anObject hash] % ([validColorsArray count]))];
 }




More information about the commits mailing list