nsresult rv;  nsCOMPtr<nsIIOService> serv; if (ioService == nsnull) { serv = do_GetIOService(&rv); if (NS_FAILED(rv)) return rv; ioService = serv.get(); }  return ioService->NewURI(spec, baseURI, result);
char* specStr = ToNewUTF8String(spec); if (specStr == nsnull) return NS_ERROR_OUT_OF_MEMORY; nsresult rv = NS_NewURI(result, specStr, baseURI, ioService); nsMemory::Free(specStr); return rv;
NS_NewURI(nsIURI* *result,           const char* spec,           nsIURI* baseURI = nsnull,          nsIIOService* ioService = nsnull)     // pass in nsIIOService to optimize callers{    nsresult rv;    nsCOMPtr<nsIIOService> serv;    if (ioService == nsnull) {        serv = do_GetIOService(&rv);        if (NS_FAILED(rv)) return rv;        ioService = serv.get();    }    return ioService->NewURI(spec, baseURI, result);}