if (aClass.Equals(kCharsetMenuCID)) { nsIFactory *factory = new nsCharsetMenuFactory(); nsresult res = factory->QueryInterface(kIFactoryIID, (void**) aFactory); if (NS_FAILED(res)) { *aFactory = NULL; delete factory; }  return res; }
extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr,                                           const nsCID &aClass,                                           const char *aClassName,                                           const char *aContractID,                                           nsIFactory **aFactory){  if (aFactory == NULL)       return NS_ERROR_NULL_POINTER;  *aFactory = NULL;   // the converter manager  if (aClass.Equals(kCharsetConverterManagerCID)) {    nsManagerFactory *factory = new nsManagerFactory();    if(nsnull == factory)       return NS_ERROR_OUT_OF_MEMORY;    nsresult res = factory->QueryInterface(kIFactoryIID, (void **) aFactory);    if (NS_FAILED(res)) {      *aFactory = NULL;      delete factory;    }    return res;  }  // the Unicode Decode helper  if (aClass.Equals(kUnicodeDecodeHelperCID)) {    nsDecodeHelperFactory *factory = new nsDecodeHelperFactory();    if(nsnull == factory)       return NS_ERROR_OUT_OF_MEMORY;    nsresult res = factory->QueryInterface(kIFactoryIID, (void **) aFactory);    if (NS_FAILED(res)) {      *aFactory = NULL;      delete factory;    }    return res;  }  // the Unicode Encode helper  if (aClass.Equals(kUnicodeEncodeHelperCID)) {    nsEncodeHelperFactory *factory = new nsEncodeHelperFactory();    if(nsnull == factory)       return NS_ERROR_OUT_OF_MEMORY;    nsresult res = factory->QueryInterface(kIFactoryIID, (void **) aFactory);    if (NS_FAILED(res)) {      *aFactory = NULL;      delete factory;    }    return res;  }  if (aClass.Equals(kPlatformCharsetCID)) {    nsIFactory *factory = NEW_PLATFORMCHARSETFACTORY();	nsresult res = factory->QueryInterface(kIFactoryIID, (void**) aFactory);    if (NS_FAILED(res)) {      *aFactory = NULL;      delete factory;    }    return res;  }  if (aClass.Equals(kCharsetAliasCID)) {    nsIFactory *factory = NEW_CHARSETALIASFACTORY();	nsresult res = factory->QueryInterface(kIFactoryIID, (void**) aFactory);    if (NS_FAILED(res)) {      *aFactory = NULL;      delete factory;    }    return res;  }  if (aClass.Equals(kCharsetMenuCID)) {    nsIFactory *factory = new nsCharsetMenuFactory();	nsresult res = factory->QueryInterface(kIFactoryIID, (void**) aFactory);    if (NS_FAILED(res)) {      *aFactory = NULL;      delete factory;    }    return res;  }  if (aClass.Equals(kTextToSubURICID)) {    nsIFactory *factory = NEW_TEXTTOSUBURI_FACTORY();	nsresult res = factory->QueryInterface(kIFactoryIID, (void**) aFactory);    if (NS_FAILED(res)) {      *aFactory = NULL;      delete factory;    }    return res;  }  return NS_NOINTERFACE;}