PRUint8 * name;
PRUint8 * name=nsnull;
LoadXPCOMPlugin(nsIRegistry* aRegistry,                const char* aFilename,                nsRegistryKey aPluginKey,                nsPluginTag** aResult){  nsresult rv;  // The name, description, MIME types, MIME descriptions, and  // supported file extensions will all hang off of the plugin's key  // in the registry. Pull these out now.  PRUint8 * name;  PRUint32 length;  aRegistry->GetBytesUTF8(aPluginKey, kPluginsNameKey, &length, &name);  PRUint8 * description;  aRegistry->GetBytesUTF8(aPluginKey, kPluginsDescKey, &length, &description);  nsXPIDLCString filename;  nsXPIDLCString fullpath;  if (!aFilename) {    // Look for a filename key    aRegistry->GetStringUTF8(aPluginKey, kPluginsFilenameKey, getter_Copies(filename));    aRegistry->GetStringUTF8(aPluginKey, kPluginsFullpathKey, getter_Copies(fullpath));  }  PRInt64 lastmod = LL_ZERO;  aRegistry->GetLongLong(aPluginKey, kPluginsModTimeKey, &lastmod);  PRInt32 intval = 1;  // Default for canunload is PR_TRUE  aRegistry->GetInt(aPluginKey, kPluginsCanUnload, &intval);  PRBool canunload = (intval > 0);  nsCOMPtr<nsIEnumerator> enumerator;  rv = aRegistry->EnumerateAllSubtrees(aPluginKey, getter_AddRefs(enumerator));  if (NS_FAILED(rv)) return rv;  nsCOMPtr<nsISimpleEnumerator> subtrees;  rv = NS_NewAdapterEnumerator(getter_AddRefs(subtrees), enumerator);  if (NS_FAILED(rv)) return rv;  char** mimetypes = nsnull;  char** mimedescriptions = nsnull;  char** extensions = nsnull;  PRInt32 count = 0;  PRInt32 capacity = 0;  for (;;) {    PRBool hasmore;    subtrees->HasMoreElements(&hasmore);    if (! hasmore)      break;    nsCOMPtr<nsISupports> isupports;    subtrees->GetNext(getter_AddRefs(isupports));    nsCOMPtr<nsIRegistryNode> node = do_QueryInterface(isupports);    NS_ASSERTION(node != nsnull, "not an nsIRegistryNode");    if (! node)      continue;    nsRegistryKey key;    node->GetKey(&key);    if (count >= capacity) {      capacity += capacity ? capacity : 4;      char** newmimetypes        = new char*[capacity];      char** newmimedescriptions = new char*[capacity];      char** newextensions       = new char*[capacity];      if (!newmimetypes || !newmimedescriptions || !newextensions) {        rv = NS_ERROR_OUT_OF_MEMORY;        delete[] newmimetypes;        delete[] newmimedescriptions;        delete[] newextensions;        break;      }      for (PRInt32 i = 0; i < count; ++i) {        newmimetypes[i]        = mimetypes[i];        newmimedescriptions[i] = mimedescriptions[i];        newextensions[i]       = extensions[i];      }      delete[] mimetypes;      delete[] mimedescriptions;      delete[] extensions;      mimetypes        = newmimetypes;      mimedescriptions = newmimedescriptions;      extensions       = newextensions;    }    aRegistry->GetStringUTF8(key, kPluginsMimeTypeKey, &mimetypes[count]);    PRUint8 * md;    aRegistry->GetBytesUTF8(key, kPluginsMimeDescKey, &length, &md);    mimedescriptions[count] = NS_REINTERPRET_CAST(char *, md);    aRegistry->GetStringUTF8(key, kPluginsMimeExtKey, &extensions[count]);    ++count;  }  if (NS_SUCCEEDED(rv)) {    // All done! Create the new nsPluginTag info and send it back.    nsPluginTag* tag      = new nsPluginTag(NS_REINTERPRET_CAST(const char *, name),                        NS_REINTERPRET_CAST(const char *, description),                        aFilename ? aFilename : filename.get(),                        fullpath.get(),                        (const char* const*)mimetypes,                        (const char* const*)mimedescriptions,                        (const char* const*)extensions,                        count, lastmod, canunload);    if (! tag)      rv = NS_ERROR_OUT_OF_MEMORY;    *aResult = tag;  }  for (PRInt32 i = 0; i < count; ++i) {    CRTFREEIF(mimetypes[i]);    CRTFREEIF(mimedescriptions[i]);    CRTFREEIF(extensions[i]);  }  delete[] mimetypes;  delete[] mimedescriptions;  delete[] extensions;  return rv;}