if(nsnull == factory) return NS_ERROR_OUT_OF_MEMORY;
if (NULL==factory) { *aFactory=NULL; return NS_ERROR_OUT_OF_MEMORY; }
extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr,                                           const nsCID &aClass,                                           const char *aClassName,                                           const char *aProgID,                                           nsIFactory **aFactory){	nsIFactory*	factoryInstance;	nsresult		res;	if (aFactory == NULL)              return NS_ERROR_NULL_POINTER;        *aFactory = NULL;	//	// first check for the nsILocaleFactory interfaces	//  	if (aClass.Equals(kLocaleFactoryCID))	{		nsLocaleFactory *factory = new nsLocaleFactory();                if(nsnull == factory)                     return NS_ERROR_OUT_OF_MEMORY;		res = factory->QueryInterface(kILocaleFactoryIID, (void **) aFactory);		if (NS_FAILED(res))		{			*aFactory = NULL;			delete factory;		}			return res;	}  if (aClass.Equals(kPosixLocaleFactoryCID))  {      nsPosixLocaleFactory *posix_factory = new nsPosixLocaleFactory();     if(nsnull == posix_factory)         return NS_ERROR_OUT_OF_MEMORY;      res = posix_factory->QueryInterface(kIFactoryIID,(void**)aFactory);      if (NS_FAILED(res))      {          *aFactory = NULL;          delete posix_factory;      }     return res;  }		//	// let the nsLocaleUnixFactory logic take over from here	//	factoryInstance = new nsLocaleUnixFactory(aClass);	if(NULL == factoryInstance) 	{		return NS_ERROR_OUT_OF_MEMORY;  	}	res = factoryInstance->QueryInterface(kIFactoryIID, (void**)aFactory);	if (NS_FAILED(res))	{		*aFactory = NULL;		delete factoryInstance;	}	return res;}