diff --git a/suite/browser/src/nsInternetSearchService.cpp b/suite/browser/src/nsInternetSearchService.cpp index 00a2ee41451..68eae652674 100755 --- a/suite/browser/src/nsInternetSearchService.cpp +++ b/suite/browser/src/nsInternetSearchService.cpp @@ -1583,13 +1583,7 @@ InternetSearchDataSource::ArcLabelsOut(nsIRDFResource *source, array->AppendElement(mNC_Child); - nsISimpleEnumerator* result = new nsArrayEnumerator(array); - if (! result) - return NS_ERROR_OUT_OF_MEMORY; - - NS_ADDREF(result); - *labels = result; - return(NS_OK); + return NS_NewArrayEnumerator(labels, array); } if ((isSearchCategoryURI(source)) && (categoryDataSource)) @@ -1776,12 +1770,7 @@ InternetSearchDataSource::GetAllCmds(nsIRDFResource* source, // always append a separator last (due to aggregation of commands from multiple datasources) cmdArray->AppendElement(mNC_BookmarkSeparator); - nsISimpleEnumerator *result = new nsArrayEnumerator(cmdArray); - if (!result) - return(NS_ERROR_OUT_OF_MEMORY); - NS_ADDREF(result); - *commands = result; - return(NS_OK); + return NS_NewArrayEnumerator(commands, cmdArray); } diff --git a/suite/browser/src/nsLocalSearchService.cpp b/suite/browser/src/nsLocalSearchService.cpp index 795fc9b5b15..bfa23d4967d 100755 --- a/suite/browser/src/nsLocalSearchService.cpp +++ b/suite/browser/src/nsLocalSearchService.cpp @@ -636,14 +636,7 @@ LocalSearchDataSource::getFindResults(nsIRDFResource *source, nsISimpleEnumerato rv = parseFindURL(source, nameArray); if (NS_FAILED(rv)) return rv; - nsISimpleEnumerator* result = new nsArrayEnumerator(nameArray); - if (! result) - return(NS_ERROR_OUT_OF_MEMORY); - - NS_ADDREF(result); - *aResult = result; - - return NS_OK; + return NS_NewArrayEnumerator(aResult, nameArray); } @@ -694,15 +687,7 @@ LocalSearchDataSource::GetTargets(nsIRDFResource *source, rv = getFindName(source, getter_AddRefs(name)); if (NS_FAILED(rv)) return rv; - nsISimpleEnumerator* result = - new nsSingletonEnumerator(name); - - if (! result) - return NS_ERROR_OUT_OF_MEMORY; - - NS_ADDREF(result); - *targets = result; - return NS_OK; + return NS_NewSingletonEnumerator(targets, name); } else if (property == kRDF_type) { @@ -711,38 +696,24 @@ LocalSearchDataSource::GetTargets(nsIRDFResource *source, if (NS_FAILED(rv)) return rv; nsAutoString url; url.AssignWithConversion(uri); - nsIRDFLiteral *literal; - rv = gRDFService->GetLiteral(url.get(), &literal); + + nsCOMPtr literal; + rv = gRDFService->GetLiteral(url.get(), + getter_AddRefs(literal)); if (NS_FAILED(rv)) return rv; - nsISimpleEnumerator* result = new nsSingletonEnumerator(literal); - - NS_RELEASE(literal); - - if (! result) - return NS_ERROR_OUT_OF_MEMORY; - - NS_ADDREF(result); - *targets = result; - return NS_OK; + return NS_NewSingletonEnumerator(targets, literal); } else if (property == kNC_pulse) { nsAutoString pulse(NS_LITERAL_STRING("15")); - nsIRDFLiteral *pulseLiteral; - rv = gRDFService->GetLiteral(pulse.get(), &pulseLiteral); + + nsCOMPtr pulseLiteral; + rv = gRDFService->GetLiteral(pulse.get(), + getter_AddRefs(pulseLiteral)); if (NS_FAILED(rv)) return rv; - nsISimpleEnumerator* result = new nsSingletonEnumerator(pulseLiteral); - - NS_RELEASE(pulseLiteral); - - if (! result) - return NS_ERROR_OUT_OF_MEMORY; - - NS_ADDREF(result); - *targets = result; - return NS_OK; + return NS_NewSingletonEnumerator(targets, pulseLiteral); } } @@ -895,13 +866,7 @@ LocalSearchDataSource::ArcLabelsOut(nsIRDFResource *source, array->AppendElement(kNC_Child); array->AppendElement(kNC_pulse); - nsISimpleEnumerator* result = new nsArrayEnumerator(array); - if (! result) - return NS_ERROR_OUT_OF_MEMORY; - - NS_ADDREF(result); - *labels = result; - return(NS_OK); + return NS_NewArrayEnumerator(labels, array); } return(NS_NewEmptyEnumerator(labels)); }