From 5d79f7bf9c89782a2a8781113b356674d3c33f9e Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Thu, 24 Feb 2011 09:02:36 -0800 Subject: Simplify memory management of CYPackageController. --- MobileCydia.mm | 42 +++++++++++------------------------------- 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/MobileCydia.mm b/MobileCydia.mm index aa9b342..483bd9b 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -5888,11 +5888,11 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { UIActionSheetDelegate > { _transient Database *database_; - Package *package_; - NSString *name_; + _H package_; + _H name_; bool commercial_; - NSMutableArray *buttons_; - UIBarButtonItem *button_; + _H buttons_; + _H button_; } - (id) initWithDatabase:(Database *)database forPackage:(NSString *)name; @@ -5901,22 +5901,8 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { @implementation CYPackageController -- (void) dealloc { - if (package_ != nil) - [package_ release]; - if (name_ != nil) - [name_ release]; - - [buttons_ release]; - - if (button_ != nil) - [button_ release]; - - [super dealloc]; -} - - (NSURL *) navigationURL { - return [NSURL URLWithString:[NSString stringWithFormat:@"cydia://package/%@", name_]]; + return [NSURL URLWithString:[NSString stringWithFormat:@"cydia://package/%@", (id) name_]]; } - (bool) _allowNavigationAction { @@ -6015,23 +6001,20 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { - (id) initWithDatabase:(Database *)database forPackage:(NSString *)name { if ((self = [super init]) != nil) { database_ = database; - buttons_ = [[NSMutableArray alloc] initWithCapacity:4]; - name_ = [[NSString alloc] initWithString:name]; - [self setURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/#!/package/%@", UI_, name_]]]; + buttons_ = [NSMutableArray arrayWithCapacity:4]; + name_ = [NSString stringWithString:name]; + [self setURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/#!/package/%@", UI_, (id) name_]]]; } return self; } - (void) reloadData { - if (package_ != nil) - [package_ autorelease]; package_ = [database_ packageWithName:name_]; [buttons_ removeAllObjects]; if (package_ != nil) { - [package_ parse]; + [(Package *) package_ parse]; - package_ = [package_ retain]; commercial_ = [package_ isCommercial]; if ([package_ mode] != nil) @@ -6047,9 +6030,6 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { [buttons_ addObject:UCLocalize("REMOVE")]; } - if (button_ != nil) - [button_ release]; - NSString *title; switch ([buttons_ count]) { case 0: title = nil; break; @@ -6057,12 +6037,12 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { default: title = UCLocalize("MODIFY"); break; } - button_ = [[UIBarButtonItem alloc] + button_ = [[[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStylePlain target:self action:@selector(customButtonClicked) - ]; + ] autorelease]; [super reloadData]; } -- cgit v1.2.3