From 1eeb1a7d68c092a9583e8750e8c7e36d58e891e1 Mon Sep 17 00:00:00 2001 From: Andrew McCreight Date: Wed, 19 Mar 2014 16:57:47 -0700 Subject: [PATCH] Bug 975823, part 2 - Take advantage of infallible new in nsStreamConverterService. r=mcmanus --- .../src/nsStreamConverterService.cpp | 40 ------------------- 1 file changed, 40 deletions(-) diff --git a/netwerk/streamconv/src/nsStreamConverterService.cpp b/netwerk/streamconv/src/nsStreamConverterService.cpp index 6ed6c3327f52..bfd9473e35e5 100644 --- a/netwerk/streamconv/src/nsStreamConverterService.cpp +++ b/netwerk/streamconv/src/nsStreamConverterService.cpp @@ -94,7 +94,6 @@ nsresult nsStreamConverterService::Init() { mAdjacencyList = new nsObjectHashtable(nullptr, nullptr, DeleteAdjacencyEntry, nullptr); - if (!mAdjacencyList) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; } @@ -173,21 +172,8 @@ nsStreamConverterService::AddAdjacency(const char *aContractID) { // There is no fromStr vertex, create one. nsCStringKey *newFromKey = new nsCStringKey(ToNewCString(fromStr), fromStr.Length(), nsCStringKey::OWN); - if (!newFromKey) return NS_ERROR_OUT_OF_MEMORY; - SCTableData *data = new SCTableData(newFromKey); - if (!data) { - delete newFromKey; - return NS_ERROR_OUT_OF_MEMORY; - } - nsCOMArray* edgeArray = new nsCOMArray; - if (!edgeArray) { - delete newFromKey; - data->key = nullptr; - delete data; - return NS_ERROR_OUT_OF_MEMORY; - } data->data.edges = edgeArray; mAdjacencyList->Put(newFromKey, data); @@ -198,21 +184,8 @@ nsStreamConverterService::AddAdjacency(const char *aContractID) { if (!mAdjacencyList->Get(&toKey)) { // There is no toStr vertex, create one. nsCStringKey *newToKey = new nsCStringKey(ToNewCString(toStr), toStr.Length(), nsCStringKey::OWN); - if (!newToKey) return NS_ERROR_OUT_OF_MEMORY; - SCTableData *data = new SCTableData(newToKey); - if (!data) { - delete newToKey; - return NS_ERROR_OUT_OF_MEMORY; - } - nsCOMArray* edgeArray = new nsCOMArray; - if (!edgeArray) { - delete newToKey; - data->key = nullptr; - delete data; - return NS_ERROR_OUT_OF_MEMORY; - } data->data.edges = edgeArray; mAdjacencyList->Put(newToKey, data); } @@ -264,17 +237,12 @@ static bool InitBFSTable(nsHashKey *aKey, void *aData, void* closure) { if (!BFSTable) return false; BFSState *state = new BFSState; - if (!state) return false; state->color = white; state->distance = -1; state->predecessor = nullptr; SCTableData *data = new SCTableData(static_cast(aKey)); - if (!data) { - delete state; - return false; - } data->data.state = state; BFSTable->Put(aKey, data); @@ -328,7 +296,6 @@ nsStreamConverterService::FindConverter(const char *aContractID, nsTArraycolor = gray; state->distance = 0; CStreamConvDeallocator *dtorFunc = new CStreamConvDeallocator(); - if (!dtorFunc) { - delete source; - return NS_ERROR_OUT_OF_MEMORY; - } nsDeque grayQ(dtorFunc); @@ -376,7 +339,6 @@ nsStreamConverterService::FindConverter(const char *aContractID, nsTArrayToString(curVertexStr); nsCStringKey *curVertex = new nsCStringKey(ToNewCString(curVertexStr), curVertexStr.Length(), nsCStringKey::OWN); - if (!curVertex) return NS_ERROR_OUT_OF_MEMORY; SCTableData *data3 = (SCTableData*)lBFSTable.Get(curVertex); if (!data3) { @@ -419,7 +381,6 @@ nsStreamConverterService::FindConverter(const char *aContractID, nsTArray *shortestPath = new nsTArray(); - if (!shortestPath) return NS_ERROR_OUT_OF_MEMORY; nsCStringKey toMIMEType(toStr); data = (SCTableData*)lBFSTable.Get(&toMIMEType); @@ -689,7 +650,6 @@ NS_NewStreamConv(nsStreamConverterService** aStreamConv) if (!aStreamConv) return NS_ERROR_NULL_POINTER; *aStreamConv = new nsStreamConverterService(); - if (!*aStreamConv) return NS_ERROR_OUT_OF_MEMORY; NS_ADDREF(*aStreamConv); nsresult rv = (*aStreamConv)->Init();