Commits

Tuukka Norri committed 96488e1

Fixed memory problems

Comments (0)

Files changed (3)

Sources/BXDatabaseContext.m

 			
             BXDatabaseObjectID* newID = [BXDatabaseObjectID IDWithEntity: currentEntity primaryKeyFields: pkeyFields];
             [superIds addObject: newID];
-            [newID release];
         }
         AddObjectIDsForInheritance2 (idsByEntity, currentEntity);
     }    
 	
 	if (NO == connected)
 	{
+		ExpectR (error, NO);
 		[self setLastConnectionError: *error];
 		if (NO == mDisplayingSheet)
 		{
 				BASETEN_BEGIN_FETCH ();
 							
 			Class databaseObjectClass = [entity databaseObjectClass];
-			retval = [mDatabaseInterface executeFetchForEntity: entity withPredicate: predicate 
+			retval = [mDatabaseInterface executeFetchForEntity: entity 
+												 withPredicate: predicate 
 											   returningFaults: returnFaults 
 														 class: databaseObjectClass
 														 error: &localError];

Sources/BXPGEFMetadataContainer.m

 	
 	while ([res advanceRow])
 	{
-		BXPGForeignKeyDescription* fkey = [[BXPGForeignKeyDescription alloc] init];
+		BXPGForeignKeyDescription* fkey = [[[BXPGForeignKeyDescription alloc] init] autorelease];
 		[fkey setIdentifier: [[res valueForKey: @"conid"] integerValue]];
 		[fkey setName: [res valueForKey: @"conname"]];
 		

Sources/PGTSFoundationObjects.m

 @implementation NSString (PGTSFoundationObjects)
 + (id) copyForPGTSResultSet: (PGTSResultSet *) set withCharacters: (const char *) value type: (PGTSTypeDescription *) typeInfo
 {
-    return [[[[NSString alloc] initWithUTF8String: value] decomposedStringWithCanonicalMapping] retain];
+	NSString *string = [[NSString alloc] initWithUTF8String: value];
+	NSString *retval = [[string decomposedStringWithCanonicalMapping] retain];
+	[string release];
+	return retval;
 }
 
 - (const char *) PGTSParameterLength: (size_t *) length connection: (PGTSConnection *) connection
 @implementation NSXMLDocument (PGTSFoundationObjects)
 + (id) copyForPGTSResultSet: (PGTSResultSet *) result withCharacters: (const char *) value type: (PGTSTypeDescription *) type columnIndex: (int) columnIndex
 {
-	id retval = nil;
 	BOOL shouldReturnDocument = NO;
-	NSData* xmlData = [[[NSData alloc] initWithBytes: value length: strlen (value)] autorelease];
+	NSData* xmlData = [[NSData alloc] initWithBytes: value length: strlen (value)];
+	id retval = xmlData;
 	PGresult* res = [result PGresult];
 	Oid relid = PQftable (res, columnIndex);
 	int attnum = PQftablecol (res, columnIndex);
 	if (shouldReturnDocument)
 	{
 		NSError* error = nil;
+		retval = nil;
 		NSXMLDocument* document = [[NSXMLDocument alloc] initWithData: xmlData options: 0 error: &error];
+		[xmlData release];
 		
 		if (document)
 			retval = document;
 		else
 			BXLogError (@"Unable to create XML document even though I was supposed to have received one. Error: %@.", error);
 	}
-	else
-	{
-		retval = [xmlData retain];
-	}
 	
 	return retval;
 }