Permalink
Browse files

Fixed potential memory leaks, warnings.

  • Loading branch information...
1 parent 23fc9b3 commit f7b6b13dbd3517ab29770e70e5366387f2539cfb @codebutler committed Sep 14, 2010
Showing with 18 additions and 13 deletions.
  1. +1 −1 Source/Classes/DockIcon.m
  2. +10 −5 Source/Classes/OAuthHelper.m
  3. +6 −6 Source/Classes/UI/FancyCell.m
  4. +1 −1 httpriot
@@ -22,7 +22,7 @@
// http://sshkeychain.sourceforge.net/
#import "DockIcon.h"
-
+#include <utime.h>
@implementation DockIcon
@@ -104,23 +104,28 @@ + (NSDictionary *)signRequest:(NSString *)url
NSString *signature = [self createSignature:baseString consumerSecret:secret];
[dict setObject:signature forKey:@"oauth_signature"];
- return dict;
+ return [dict autorelease];
}
+ (NSString *)generateTimestamp {
- return [[NSString stringWithFormat:@"%d", time(NULL)] retain];
+ return [NSString stringWithFormat:@"%d", time(NULL)];
}
+ (NSString *)generateNonce {
CFUUIDRef uuidObj = CFUUIDCreate(nil);
+
NSString *uuidString = (NSString*)CFUUIDCreateString(nil, uuidObj);
CFRelease(uuidObj);
- return [uuidString autorelease];
+
+ NSString *copy = [NSString stringWithString:uuidString];
+ CFRelease(uuidString);
+
+ return copy;
}
+ (NSString *)createParamString:(NSDictionary *)params
{
- NSMutableArray *paramArray = [NSMutableArray new];
+ NSMutableArray *paramArray = [[NSMutableArray new] autorelease];
for (id key in params) {
id val = [params objectForKey:key];
[paramArray addObject:[NSString stringWithFormat:@"%@=%@", [key URLEncodedString], [val URLEncodedString]]];
@@ -136,7 +141,7 @@ + (NSString *)createSignature:(NSString *)text consumerSecret:(NSString *)secret
unsigned char result[20];
CCHmac(kCCHmacAlgSHA1, [secretData bytes], [secretData length], [clearTextData bytes], [clearTextData length], result);
- NSData *hmac = [[NSData alloc] initWithBytes:result length:sizeof(result)];
+ NSData *hmac = [[[NSData alloc] initWithBytes:result length:sizeof(result)] autorelease];
return [hmac base64Encoding];
}
@@ -92,9 +92,9 @@ - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
CGFloat width = cellFrame.size.width - x - badgeWidth - 6;
NSRect rect = NSMakeRect(x, cellFrame.origin.y, width, cellFrame.size.height);
if ([item isGroup]) {
- NSMutableDictionary *groupTextAttributes = [primaryTextAttributes mutableCopy];
+ NSMutableDictionary *groupTextAttributes = [[primaryTextAttributes mutableCopy] autorelease];
[groupTextAttributes setValue:secondaryColor forKey:NSForegroundColorAttributeName];
- NSShadow *textShadow = [NSShadow alloc];
+ NSShadow *textShadow = [[NSShadow alloc] autorelease];
[textShadow setShadowOffset:NSMakeSize(0,-1)];
[textShadow setShadowBlurRadius:1.0];
[textShadow setShadowColor:[NSColor colorWithDeviceWhite:1 alpha:1.0]];
@@ -198,7 +198,7 @@ - (int)drawBadgeInRect:(NSRect)aRect
[[NSColor colorWithCalibratedRed:.53 green:.60 blue:.74 alpha:1.0] set];
[badgePath fill];
- NSDictionary *dict = [[NSMutableDictionary alloc] init];
+ NSDictionary *dict = [[[NSMutableDictionary alloc] init] autorelease];
[dict setValue:[NSFont boldSystemFontOfSize:11] forKey:NSFontAttributeName];
[dict setValue:[NSNumber numberWithFloat:-.25] forKey:NSKernAttributeName];
[dict setValue:[NSColor whiteColor] forKey:NSForegroundColorAttributeName];
@@ -209,7 +209,7 @@ - (int)drawBadgeInRect:(NSRect)aRect
// The row is selected and the window is in focus.
[[NSColor whiteColor] set];
[badgePath fill];
- NSDictionary *dict = [[NSMutableDictionary alloc] init];
+ NSDictionary *dict = [[[NSMutableDictionary alloc] init] autorelease];
[dict setValue:[NSFont boldSystemFontOfSize:11] forKey:NSFontAttributeName];
[dict setValue:[NSNumber numberWithFloat:-.25] forKey:NSKernAttributeName];
[dict setValue:[NSColor alternateSelectedControlColor] forKey:NSForegroundColorAttributeName];
@@ -220,7 +220,7 @@ - (int)drawBadgeInRect:(NSRect)aRect
// The row is not selected and the window is not in focus.
[[NSColor disabledControlTextColor] set];
[badgePath fill];
- NSDictionary *dict = [[NSMutableDictionary alloc] init];
+ NSDictionary *dict = [[[NSMutableDictionary alloc] init] autorelease];
[dict setValue:[NSFont boldSystemFontOfSize:11] forKey:NSFontAttributeName];
[dict setValue:[NSNumber numberWithFloat:-.25] forKey:NSKernAttributeName];
[dict setValue:[NSColor whiteColor] forKey:NSForegroundColorAttributeName];
@@ -231,7 +231,7 @@ - (int)drawBadgeInRect:(NSRect)aRect
// The row is selected and the window is not in focus.
[[NSColor whiteColor] set];
[badgePath fill];
- NSDictionary *dict = [[NSMutableDictionary alloc] init];
+ NSDictionary *dict = [[[NSMutableDictionary alloc] init] autorelease];
[dict setValue:[NSFont boldSystemFontOfSize:11] forKey:NSFontAttributeName];
[dict setValue:[NSNumber numberWithFloat:-.25] forKey:NSKernAttributeName];
[dict setValue:[NSColor disabledControlTextColor] forKey:NSForegroundColorAttributeName];

0 comments on commit f7b6b13

Please sign in to comment.