sprintf(buff, "%s/%s", "software/netscape/intl/uconv", (g_FactoryData[i].mCID -> ToString()));
char *cidString = g_FactoryData[i].mCID->ToString(); sprintf(buff, "%s/%s", "software/netscape/intl/uconv", cidString); delete [] cidString;
extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports * aServMgr,                                              const char * path){  nsresult res;  PRUint32 i;  nsIComponentManager * compMgr = NULL;  nsIRegistry * registry = NULL;  nsIRegistry::Key key;  char buff[1024];  // get the service manager  nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &res));  // get the component manager  res = servMgr->GetService(kComponentManagerCID,                             nsIComponentManager::GetIID(),                             (nsISupports**)&compMgr);  if (NS_FAILED(res)) goto done;  // get the registry  res = servMgr->GetService(NS_REGISTRY_PROGID,                             nsIRegistry::GetIID(),                             (nsISupports**)&registry);  if (NS_FAILED(res)) goto done;  // open the registry  res = registry->OpenWellKnownRegistry(      nsIRegistry::ApplicationComponentRegistry);  if (NS_FAILED(res)) goto done;  char name[128];  char progid[128];  for (i=0; i<ARRAY_SIZE(g_FactoryData); i++) {    if(0==PL_strcmp(g_FactoryData[i].mCharsetSrc,"Unicode"))    {       PL_strcpy(name, DECODER_NAME_BASE);       PL_strcat(name, g_FactoryData[i].mCharsetDest);       PL_strcpy(progid, NS_UNICODEDECODER_PROGID_BASE);       PL_strcat(progid, g_FactoryData[i].mCharsetDest);    } else {       PL_strcpy(name, ENCODER_NAME_BASE);       PL_strcat(name, g_FactoryData[i].mCharsetSrc);       PL_strcpy(progid, NS_UNICODEENCODER_PROGID_BASE);       PL_strcat(progid, g_FactoryData[i].mCharsetSrc);    }    // register component    res = compMgr->RegisterComponent(*(g_FactoryData[i].mCID), name, progid,      path, PR_TRUE, PR_TRUE);    if(NS_FAILED(res) && (NS_ERROR_FACTORY_EXISTS != res)) goto done;    // register component info    // XXX take these KONSTANTS out of here    // XXX free the string from "ToString()"    sprintf(buff, "%s/%s", "software/netscape/intl/uconv", (g_FactoryData[i].mCID -> ToString()));    res = registry -> AddSubtree(nsIRegistry::Common, buff, &key);    if (NS_FAILED(res)) goto done;    res = registry -> SetString(key, "source", g_FactoryData[i].mCharsetSrc);    if (NS_FAILED(res)) goto done;    res = registry -> SetString(key, "destination", g_FactoryData[i].mCharsetDest);    if (NS_FAILED(res)) goto done;  }done:  if (compMgr != NULL)     (void)servMgr->ReleaseService(kComponentManagerCID, compMgr);  if (registry != NULL) {    registry -> Close();    (void)servMgr->ReleaseService(NS_REGISTRY_PROGID, registry);  }  return res;}