Chameleon Applications

Chameleon Applications Commit Details

Date:2011-11-24 05:41:44 (12 years 4 months ago)
Author:Rekursor
Commit:367
Parents: 366
Message:fixed little memry leaks
Changes:
M/trunk/ChameleonPrefPane/Sources/RoundedBox.m
M/trunk/ChameleonPrefPane/Sources/PartitionInfoElement.h
M/trunk/ChameleonPrefPane/Sources/PartitionInfoElement.mm

File differences

trunk/ChameleonPrefPane/Sources/RoundedBox.m
100100
101101
102102
103
104
103
105104
106105
107106
// Construct rounded rect path
NSRect boxRect = [self bounds];
NSRect bgRect = boxRect;
bgRect = NSInsetRect(boxRect, borderWidth / 2.0, borderWidth / 2.0);
NSRect bgRect = NSInsetRect(boxRect, borderWidth / 2.0, borderWidth / 2.0);
bgRect = NSIntegralRect(bgRect);
bgRect.origin.x += 0.5;
bgRect.origin.y += 0.5;
trunk/ChameleonPrefPane/Sources/PartitionInfoElement.h
3939
4040
4141
42
4243
4344
4445
......
6162
6263
6364
65
6466
-(id)initWithBSDName: (NSString*) bsdName;
-(id)initWithBSDName: (NSString*) bsdName withinSession: (DASessionRef) session;
-(void) cleanup;
-(int)extractInfoWithBSDName: (NSString*) bsdName;
-(int)extractInfoWithBSDName: (NSString*) bsdName withinSession:(DASessionRef) session;
-(bool) isBootable;
-(int) imageIndexFromFs;
+(NSString*) removesSpacesFromLabel:(NSString*) label;
@end
trunk/ChameleonPrefPane/Sources/PartitionInfoElement.mm
8989
9090
9191
92
93
94
95
92
93
94
95
96
97
98
9699
97100
98101
......
140143
141144
142145
146
147
143148
144
145
146
147
149
150
151
152
153
154
155
148156
149157
150158
151159
152160
161
153162
154163
155164
......
157166
158167
159168
160
161169
162170
163171
......
192200
193201
194202
195
203
196204
197205
198206
......
280288
281289
282290
283
284
291
285292
286
293
294
287295
288296
289297
290298
291299
300
301
302
303
304
292305
293
294
306
307
308
309
295310
296311
297312
/// Extract a particular information from the disk partition dictionary from a key, generate a string value output
-(NSString*) createStringValueWithKey: (NSString*) key
{
if (err) return @"";
CFTypeRef o = [descDict objectForKey: key];
if (o==nil) return @"";
return (NSString*) CFStringCreateWithFormat(NULL, NULL, CFSTR("%@"), o);
if (err) return @"";
CFTypeRef o = [descDict objectForKey: key];
if (o==nil) return @"";
CFStringRef sref = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@"), o);
NSString* s = [[((NSString*) sref) copy] autorelease];
CFRelease(sref);
return s;
}
/// main extraction method create a dictionary containing all needed information from disk arbitration API
if (disk == NULL) err = EINVAL;
}
[self cleanup];
if (err == 0) {
descDict = (NSDictionary*) DADiskCopyDescription(disk);
[descDict retain];
if (descDict == NULL) err = EINVAL;
CFDictionaryRefdr = DADiskCopyDescription(disk);
if (dr!=NULL)
{
self.descDict = [((NSDictionary*) dr) copy];
CFRelease(dr);
if (self.descDict == NULL) err = EINVAL;
}
}
if (err == 0) {
self.vUUID = [self createStringValueWithKey: @"DAVolumeUUID"];
self.vName = [self createStringValueWithKey: @"DAVolumeName"];
self.vAliasName = self.vName; // by default renamed = original part name
self.vKind = [self createStringValueWithKey: @"DAVolumeKind"];
self.mediaPath = [self createStringValueWithKey: @"DAMediaPath"];
self.devProtocol = [self createStringValueWithKey: @"DADeviceProtocol"];
devInternal = (bool) [[descDict objectForKey: @"DADeviceInternal"] boolValue];
mediaRemovable = (bool) [[descDict objectForKey: @"DAMediaRemovable"] boolValue];
self.vAliasName = self.vName; // by default renamed = original part name
}
// Clean up.
}
if (session!=nil) CFRelease(session);
}
[partArr release];
return arr;
}
return self;
}
/// release created objects
-(void) dealloc
-(void) cleanup
{
if (descDict != nil) [descDict release];
if (descDict != nil) CFRelease(descDict);
if (bsdName != nil) [bsdName release];
if (vUUID != nil) [vUUID release];
if (vKind != nil) [vKind release];
if (vName != nil) [vName release];
if (mediaPath != nil) [mediaPath release];
if (devProtocol != nil) [devProtocol release];
if (vAliasName != nil) [vAliasName release];
bsdName = vUUID = vKind = vName = mediaPath = devProtocol = vAliasName = nil;
descDict = nil;
}
if (vAliasName != nil) [vAliasName release];
/// release created objects
-(void) dealloc
{
[self cleanup];
[super dealloc];
}

Archive Download the corresponding diff file

Revision: 367