NS_RELEASE(i);
extern "C" JSBool pref_InitInitialObjects()// Initialize default preference JavaScript buffers from// appropriate TEXT resources//----------------------------------------------------------------------------------------{    JSBool funcResult;    nsresult rv;    NS_WITH_SERVICE(nsIFileLocator, locator, kFileLocatorCID, &rv);    if (NS_FAILED(rv))    	return JS_TRUE;    nsIFileSpec* componentsDir;    rv = locator->GetFileLocation(nsSpecialFileSpec::App_ComponentsDirectory, &componentsDir);    if (NS_FAILED(rv))    	return JS_TRUE;	static const char* specialFiles[] = {		"initpref.js"#ifdef XP_MAC	,	"macprefs.js"#elif defined(XP_PC)	,	"winpref.js"#elif defined(XP_UNIX)	,	"unix.js"#endif	};    	int k;	JSBool worked = JS_FALSE;	// Parse all the random files that happen to be in the components directory.    nsIDirectoryIterator* i = nsnull;    rv = nsComponentManager::CreateInstance(        	(const char*)NS_DIRECTORYITERATOR_PROGID,        	(nsISupports*)nsnull,        	(const nsID&)nsIDirectoryIterator::GetIID(),        	(void**)&i);    NS_ASSERTION(NS_SUCCEEDED(rv), "ERROR: Could not make a directory iterator.");    if (!i || NS_FAILED(i->Init(componentsDir, PR_TRUE)))    	return JS_FALSE;	// Get any old child of the components directory. Warning: aliases get resolved, so	// SetLeafName will not work here.    nsIFileSpec* specialChild;    rv = locator->GetFileLocation(nsSpecialFileSpec::App_ComponentsDirectory, &specialChild);    if (NS_FAILED(rv))    	return JS_TRUE;	if NS_FAILED(specialChild->AppendRelativeUnixPath((char*)specialFiles[0]))	{		funcResult = JS_FALSE;		goto done;	}	    worked = (JSBool)(pref_OpenFileSpec(    	specialChild,    	PR_FALSE,    	PR_FALSE,    	PR_FALSE,    	PR_FALSE) == PREF_NOERROR);	NS_ASSERTION(worked, "initpref.js not parsed successfully");	// Keep this child	for (; Exists(i); i->Next())	{		nsIFileSpec* child;		PRBool shouldParse = PR_TRUE;		if NS_FAILED(i->GetCurrentSpec(&child))			continue;		char* leafName;		rv = child->GetLeafName(&leafName);		if NS_FAILED(rv)			goto next_child;		// Skip non-js files		if (strstr(leafName, ".js") + strlen(".js") != leafName + strlen(leafName))			shouldParse = PR_FALSE;		// Skip files in the special list.		if (shouldParse)		{			for (int j = 0; j < (int) (sizeof(specialFiles) / sizeof(char*)); j++)				if (strcmp(leafName, specialFiles[j]) == 0)					shouldParse = PR_FALSE;		}		nsCRT::free((char*)leafName);		if (shouldParse)		{		    worked = (JSBool)(pref_OpenFileSpec(		    	child,		    	PR_FALSE,		    	PR_FALSE,		    	PR_FALSE,		    	PR_FALSE) == PREF_NOERROR);			NS_ASSERTION(worked, "Config file not parsed successfully");		}	next_child:		NS_IF_RELEASE(child);	}	// Finally, parse any other special files (platform-specific ones).	for (k = 1; k < (int) (sizeof(specialFiles) / sizeof(char*)); k++)	{        nsIFileSpec* specialChild2;        if (NS_FAILED(locator->GetFileLocation(nsSpecialFileSpec::App_ComponentsDirectory, &specialChild2)))	    	continue;		if (NS_FAILED(specialChild2->AppendRelativeUnixPath((char*)specialFiles[k])))	    	continue;	    worked = (JSBool)(pref_OpenFileSpec(    		specialChild2,	    	PR_FALSE,	    	PR_FALSE,	    	PR_FALSE,	    	PR_FALSE) == PREF_NOERROR);		NS_ASSERTION(worked, "<platform>.js was not parsed successfully");		NS_RELEASE(specialChild2);	}done:	NS_RELEASE(specialChild);    return JS_TRUE;}