зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1153267 - part 2 - use smart pointers instead of manual NS_ADDREF'ing outparams; r=ehsan
This commit is contained in:
Родитель
2b1ae6e2ca
Коммит
dbc40671bc
|
@ -1214,15 +1214,13 @@ nsJSProtocolHandler::NewChannel2(nsIURI* uri,
|
|||
nsIChannel** result)
|
||||
{
|
||||
nsresult rv;
|
||||
nsJSChannel * channel;
|
||||
|
||||
NS_ENSURE_ARG_POINTER(uri);
|
||||
|
||||
channel = new nsJSChannel();
|
||||
nsRefPtr<nsJSChannel> channel = new nsJSChannel();
|
||||
if (!channel) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
NS_ADDREF(channel);
|
||||
|
||||
rv = channel->Init(uri);
|
||||
|
||||
|
@ -1231,10 +1229,8 @@ nsJSProtocolHandler::NewChannel2(nsIURI* uri,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
*result = channel;
|
||||
NS_ADDREF(*result);
|
||||
channel.forget(result);
|
||||
}
|
||||
NS_RELEASE(channel);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -90,19 +90,16 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(nsXULPrototypeDocument)
|
|||
NS_IMETHODIMP
|
||||
NS_NewXULPrototypeDocument(nsXULPrototypeDocument** aResult)
|
||||
{
|
||||
*aResult = new nsXULPrototypeDocument();
|
||||
if (! *aResult)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*aResult = nullptr;
|
||||
nsRefPtr<nsXULPrototypeDocument> doc =
|
||||
new nsXULPrototypeDocument();
|
||||
|
||||
nsresult rv;
|
||||
rv = (*aResult)->Init();
|
||||
nsresult rv = doc->Init();
|
||||
if (NS_FAILED(rv)) {
|
||||
delete *aResult;
|
||||
*aResult = nullptr;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_ADDREF(*aResult);
|
||||
doc.forget(aResult);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -583,12 +583,11 @@ nsXULTemplateQueryProcessorRDF::TranslateRef(nsISupports* aDatasource,
|
|||
nsCOMPtr<nsIRDFResource> uri;
|
||||
gRDFService->GetUnicodeResource(aRefString, getter_AddRefs(uri));
|
||||
|
||||
nsXULTemplateResultRDF* refresult = new nsXULTemplateResultRDF(uri);
|
||||
nsRefPtr<nsXULTemplateResultRDF> refresult = new nsXULTemplateResultRDF(uri);
|
||||
if (! refresult)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
*aRef = refresult;
|
||||
NS_ADDREF(*aRef);
|
||||
refresult.forget(aRef);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -326,12 +326,11 @@ nsXULTemplateQueryProcessorXML::GenerateResults(nsISupports* aDatasource,
|
|||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
nsXULTemplateResultSetXML* results =
|
||||
nsRefPtr<nsXULTemplateResultSetXML> results =
|
||||
new nsXULTemplateResultSetXML(xmlquery, exprresults.forget(),
|
||||
xmlquery->GetBindingSet());
|
||||
|
||||
*aResults = results;
|
||||
NS_ADDREF(*aResults);
|
||||
results.forget(aResults);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -385,8 +384,8 @@ nsXULTemplateQueryProcessorXML::TranslateRef(nsISupports* aDatasource,
|
|||
if (!rootElement)
|
||||
return NS_OK;
|
||||
|
||||
*aRef = new nsXULTemplateResultXML(nullptr, rootElement, nullptr);
|
||||
NS_ADDREF(*aRef);
|
||||
nsRefPtr<nsXULTemplateResultXML> result = new nsXULTemplateResultXML(nullptr, rootElement, nullptr);
|
||||
result.forget(aRef);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -170,19 +170,16 @@ nsDirectoryIndexStream::~nsDirectoryIndexStream()
|
|||
nsresult
|
||||
nsDirectoryIndexStream::Create(nsIFile* aDir, nsIInputStream** aResult)
|
||||
{
|
||||
nsDirectoryIndexStream* result = new nsDirectoryIndexStream();
|
||||
nsRefPtr<nsDirectoryIndexStream> result = new nsDirectoryIndexStream();
|
||||
if (! result)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult rv;
|
||||
rv = result->Init(aDir);
|
||||
nsresult rv = result->Init(aDir);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete result;
|
||||
return rv;
|
||||
}
|
||||
|
||||
*aResult = result;
|
||||
NS_ADDREF(*aResult);
|
||||
result.forget(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче