mDecArray[mEncSize].mFreeCID = PR_TRUE;
mDecArray[mDecSize].mFreeCID = PR_TRUE;
nsresult nsCharsetConverterManager::CreateMapping(){  mMappingDone = PR_TRUE;  nsresult res = NS_OK;  nsIRegistry * registry = NULL;  nsIEnumerator * components = NULL;  nsIRegistry::Key uconvKey, key;  // XXX hack; make these dynamic  mEncArray = new ConverterInfo [100];  mDecArray = new ConverterInfo [100];  mEncSize = mDecSize = 0;  // get the registry  res = nsServiceManager::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;  // get subtree  res = registry -> GetSubtree(nsIRegistry::Common,                                "software/netscape/intl/uconv",                                &uconvKey);  if (NS_FAILED(res)) goto done;  // enumerate subtrees  res = registry -> EnumerateSubtrees(uconvKey, &components);  if (NS_FAILED(res)) goto done;  res = components -> First();  if (NS_FAILED(res)) goto done;  // XXX take these KONSTANTS out of here  // XXX check return values, free stuff  // XXX bit hacky, clean me up  while (NS_OK != components -> IsDone()) {    nsISupports * base;    res = components -> CurrentItem(&base);    if (NS_SUCCEEDED(res)) {      nsIRegistryNode * node;      nsIID nodeIID = NS_IREGISTRYNODE_IID;      res = base->QueryInterface (nodeIID, (void**)&node);      if (NS_FAILED(res)) continue;      char *name;      res = node->GetName(&name);      if (NS_FAILED(res)) continue;      nsCID * cid = new nsCID();      char * src;      char * dest;      if (!cid->Parse(name)) continue;      res = node->GetKey(&key);      if (NS_FAILED(res)) continue;      res = registry->GetString(key, "source", &src);      if (NS_FAILED(res)) continue;      res = registry->GetString(key, "destination", &dest);      if (NS_FAILED(res)) {          nsCRT::free(src);          continue;      }      nsAutoString str;      if (!strcmp(src, "Unicode")) {        str.Assign(dest);        GetCharsetName(&str,&mEncArray[mEncSize].mCharset);        mEncArray[mEncSize].mCID = cid;        mEncArray[mEncSize].mFreeCID = PR_TRUE;        mEncSize++;      } else if (!strcmp(dest, "Unicode")) {        str.Assign(src);        GetCharsetName(&str,&mDecArray[mDecSize].mCharset);        mDecArray[mDecSize].mCID = cid;        mDecArray[mEncSize].mFreeCID = PR_TRUE;        mDecSize++;      }      nsCRT::free(src);      nsCRT::free(dest);      nsCRT::free(name);      NS_RELEASE(node);      NS_RELEASE(base);    }    res = components->Next();  }done:  if (registry != NULL) {    registry -> Close();    nsServiceManager::ReleaseService(NS_REGISTRY_PROGID, registry);  }  NS_IF_RELEASE(components);  return res;}