NS_ADDREF(m_reg);
NS_IMETHODIMP nsProfile::UpdateMozProfileRegistry(){	nsresult rv = NS_OK;#ifdef XP_PC#if defined(DEBUG_profile)    printf("Entered MigrateProfileInfo.\n");#endif	for (int index = 0; index < g_numOldProfiles; index++)	{		// Check result.		if (m_reg != nsnull)		{			// Latch onto the registry object.			NS_ADDREF(m_reg);			// Open the registry file.			rv = m_reg->Open();    			if (NS_SUCCEEDED(rv))			{				nsIRegistry::Key key;				rv = m_reg->GetSubtree(nsIRegistry::Common, "Profiles", &key);				if (NS_SUCCEEDED(rv))				{					nsIRegistry::Key newKey;					rv = m_reg->SetString(key, "NeedMigration", "true");					rv = m_reg->GetSubtree(key, gOldProfiles[index], &newKey);								if (NS_FAILED(rv))					{						rv = m_reg->AddSubtree(key, gOldProfiles[index], &newKey);								if (NS_SUCCEEDED(rv))						{							nsFileSpec profileDir(gOldProfLocations[index]);													nsPersistentFileDescriptor descriptor(profileDir);							char* profileDirString = nsnull;							nsOutputStringStream stream(profileDirString);							stream << descriptor;  							if (profileDirString && *profileDirString)							{								rv = m_reg->SetString(newKey, "directory", profileDirString);									if (NS_FAILED(rv))								{									#if defined(DEBUG_profile)										printf("Couldn't set directory property.\n" );									#endif								}															rv = m_reg->SetString(newKey, "migrated", "no");															if (NS_FAILED(rv))								{									#if defined(DEBUG_profile)										printf("Couldn't add migrate flag.\n" );									#endif								}							}							else							{								#if defined(DEBUG_profile)									printf("NULL value received for directory name.\n" );								#endif							}							delete [] profileDirString;						}						else						{							#if defined(DEBUG_profile)								printf("Profiles : Could not add profile subtree.\n" );							#endif						}					}					else					{						#if defined(DEBUG_profile)							printf("Profiles : Profile name subtree already exists.\n" );						#endif					}				}				else				{					#if defined(DEBUG_profile)						printf("Registry : Couldn't get Profiles subtree.\n");					#endif				}			    m_reg->Close();			}			else			{				#if defined(DEBUG_profile)					printf("Couldn't open registry.\n");				#endif			}		}		}#endif	return rv;}