rv = result->Init(uri);
rv = result->Init(aURI);
ServiceImpl::GetResource(const char* uri, nsIRDFResource** resource){    nsIRDFResource* result =        NS_STATIC_CAST(nsIRDFResource*, PL_HashTableLookup(mResources, uri));        if (result) {        // Addref for the callee.        NS_ADDREF(result);        *resource = result;        return NS_OK;    }                    nsresult rv;    nsAutoString uriStr = uri;    PRInt32 pos = uriStr.Find(':');    if (pos < 0) {        // no colon, so try the default resource factory#if HACK_DONT_USE_LIBREG        nsIServiceManager* servMgr;        nsServiceManager::GetGlobalServiceManager(&servMgr);        nsIFactory* fact;        rv = NSGetFactory(servMgr, kRDFDefaultResourceCID,                          "", NS_RDF_RESOURCE_FACTORY_PROGID, &fact);        if (rv == NS_OK) {            rv = fact->CreateInstance(nsnull, nsIRDFResource::IID(),                                      (void**)&result);            NS_RELEASE(fact);        }#else        rv = nsRepository::CreateInstance(NS_RDF_RESOURCE_FACTORY_PROGID,                                          nsnull, nsIRDFResource::IID(),                                          (void**)&result);#endif        if (NS_FAILED(rv)) return rv;    }    else {        nsAutoString prefix;        uriStr.Left(prefix, pos);      // truncate        char* prefixStr = prefix.ToNewCString();        if (prefixStr == nsnull)            return NS_ERROR_OUT_OF_MEMORY;        char* progID = PR_smprintf(NS_RDF_RESOURCE_FACTORY_PROGID_PREFIX "%s",                                   prefixStr);        delete[] prefixStr;        if (progID == nsnull)            return NS_ERROR_OUT_OF_MEMORY;#if HACK_DONT_USE_LIBREG        nsIServiceManager* servMgr;        nsServiceManager::GetGlobalServiceManager(&servMgr);        nsIFactory* fact;        rv = NSGetFactory(servMgr, kRDFDefaultResourceCID,                          "", progID, &fact);        if (rv == NS_OK) {            rv = fact->CreateInstance(nsnull, nsIRDFResource::IID(),                                      (void**)&result);            NS_RELEASE(fact);        }#else        rv = nsRepository::CreateInstance(progID, nsnull,                                          nsIRDFResource::IID(),                                          (void**)&result);#endif        PR_smprintf_free(progID);        if (NS_FAILED(rv)) {            // if we failed, try the default resource factory#if HACK_DONT_USE_LIBREG            nsIServiceManager* servMgr;            nsServiceManager::GetGlobalServiceManager(&servMgr);            nsIFactory* fact;            rv = NSGetFactory(servMgr, kRDFDefaultResourceCID,                              "", NS_RDF_RESOURCE_FACTORY_PROGID, &fact);            if (rv == NS_OK) {                rv = fact->CreateInstance(nsnull, nsIRDFResource::IID(),                                          (void**)&result);                NS_RELEASE(fact);            }#else            rv = nsRepository::CreateInstance(NS_RDF_RESOURCE_FACTORY_PROGID,                                              nsnull, nsIRDFResource::IID(),                                              (void**)&result);#endif            if (NS_FAILED(rv)) return rv;        }    }    rv = result->Init(uri);    if (NS_FAILED(rv)) {        NS_RELEASE(result);        return rv;    }    *resource = result;    rv = RegisterResource(result);    if (NS_FAILED(rv))        NS_RELEASE(result);    return rv;}