Solving memory leaks
Solving memory leaks
- Subject: Solving memory leaks
- From: Michael Davey <email@hidden>
- Date: Sun, 28 Mar 2010 18:37:57 +0100
> -(NSDictionary *)fetch {
> NSMutableDictionary *output = nil;
> if (db != nil && sth != nil) {
> int c = sqlite3_column_count(sth);
> if (fields == nil) {
> fields = [[NSMutableArray alloc] init];
> for (int i = 0; i < c; ++i) {
> const char *name = sqlite3_column_name(sth, i);
> [fields addObject:[NSString stringWithUTF8String:name]];
> }
> }
> if (sqlite3_step(sth) == SQLITE_ROW) {
> output = [[[NSMutableDictionary alloc] init] autorelease];
> for (int i = 0; i < c; ++i) {
> const unsigned char *val = sqlite3_column_text(sth, i);
> NSString *value;
> if (val == nil) {
> value = @"{NULL}";
> }
> else {
> value = [NSString stringWithUTF8String:(char *)val];
> }
> [output setObject:value forKey:[fields objectAtIndex:i]];
> }
> }
> }
> return output;
> }
However, can anyone answer how I best go about either of the tasks that I have outlined as red, as they are leaking a lot of memory in comparison?_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden