nsCRT::free(profileName);
NS_IMETHODIMP nsProfile::CreateNewProfile(const char* charData){	nsresult rv = NS_OK;#if defined(DEBUG_profile)    printf("ProfileManager : CreateNewProfile\n");    printf("ProfileManagerData*** : %s\n", charData);#endif    NS_WITH_SERVICE(nsIFileLocator, locator, kFileLocatorCID, &rv);	if (NS_FAILED(rv) || !locator)		return NS_ERROR_FAILURE;    nsString data(charData);    	// Set the gathered info into an array	SetDataArray(data);    	char* dirName = GetValue("ProfileDir");    char* unescapedProfileName = GetValue("ProfileName");    	if (!unescapedProfileName || !*unescapedProfileName)		return NS_ERROR_FAILURE;	// Escape profile name to create a valid direrctory, 	// if directory value is not provided	char* profileName = nsEscape(unescapedProfileName, url_Path); // temp hack      	nsFileSpec dirSpec(dirName);	if (!dirName || !*dirName)    {		// They didn't type a directory path...		// Get current profile, make the new one a sibling...	    nsCOMPtr <nsIFileSpec> horribleCOMDirSpecThing;        rv = locator->GetFileLocation(nsSpecialFileSpec::App_DefaultUserProfileRoot50, getter_AddRefs(horribleCOMDirSpecThing));        		if (NS_FAILED(rv) || !horribleCOMDirSpecThing)			return NS_ERROR_FAILURE;		//Append profile name to form a directory name	    horribleCOMDirSpecThing->GetFileSpec(&dirSpec);		//dirSpec.SetLeafName(profileName);		//dirSpec += profileName;	}#if defined(DEBUG_profile)	printf("before SetProfileDir\n");#endif	if (!dirSpec.Exists())		dirSpec.CreateDirectory();	dirSpec += profileName;	// Set the directory value and add the entry to the registry tree.	// Creates required user directories.    rv = SetProfileDir(unescapedProfileName, dirSpec);	PR_DELETE(unescapedProfileName);#if defined(DEBUG_profile)    printf("after SetProfileDir\n");#endif	if (NS_FAILED(rv))	{		nsCRT::free(profileName);		return rv;	}    // Get profile defaults folder..    nsCOMPtr <nsIFileSpec> profDefaultsDir;    rv = locator->GetFileLocation(nsSpecialFileSpec::App_ProfileDefaultsFolder50, getter_AddRefs(profDefaultsDir));        	if (NS_FAILED(rv) || !profDefaultsDir)	{		nsCRT::free(profileName);		return NS_ERROR_FAILURE;	}	nsFileSpec defaultsDirSpec;	profDefaultsDir->GetFileSpec(&defaultsDirSpec);	// Copy contents from defaults folder.	if (defaultsDirSpec.Exists())	{		defaultsDirSpec.RecursiveCopy(dirSpec);	}	if (dirName)	{		PR_DELETE(dirName);	}	nsCRT::free(profileName);    return NS_OK;}