if (prevRes && !replace) { NS_WARNING("resource already registered, and replace not specified"); return NS_ERROR_FAILURE;
(*hep)->value = aResource; } else { const char* key = PL_strdup(uri); if (! key) return NS_ERROR_OUT_OF_MEMORY;  PL_HashTableAdd(mResources, key, aResource);
ServiceImpl::RegisterResource(nsIRDFResource* aResource, PRBool replace){    NS_PRECONDITION(aResource != nsnull, "null ptr");    if (! aResource)        return NS_ERROR_NULL_POINTER;    nsresult rv;    nsXPIDLCString uri;    rv = aResource->GetValue(getter_Copies(uri));    if (NS_FAILED(rv)) {        NS_ERROR("unable to get URI from resource");        return rv;    }    NS_ASSERTION(uri != nsnull, "resource has no URI");    if (! uri)        return NS_ERROR_NULL_POINTER;    nsIRDFResource* prevRes =        NS_STATIC_CAST(nsIRDFResource*, PL_HashTableLookup(mResources, uri));    if (prevRes && !replace) {        NS_WARNING("resource already registered, and replace not specified");        return NS_ERROR_FAILURE;    // already registered    }    if (prevRes) {        // XXXwaterson: LEAK! Release the previous key.    }    const char* key = PL_strdup(uri);    if (! key)        return NS_ERROR_OUT_OF_MEMORY;    PL_HashTableAdd(mResources, key, aResource);    // *We* don't AddRef() the resource: that way, the resource    // can be garbage collected when the last refcount goes    // away. The single addref that the CreateResource() call made    // will be owned by the callee.    return NS_OK;}