From c570740f97d4c2aca8cda37f1d7713a1e4d584a0 Mon Sep 17 00:00:00 2001 From: Andrew McCreight Date: Fri, 21 Mar 2014 09:43:40 -0700 Subject: [PATCH] Bug 975823, part 4 - SCTableData doesn't use its key field. r=mcmanus --- .../src/nsStreamConverterService.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/netwerk/streamconv/src/nsStreamConverterService.cpp b/netwerk/streamconv/src/nsStreamConverterService.cpp index 4fe16d4b520..074d91b92b7 100644 --- a/netwerk/streamconv/src/nsStreamConverterService.cpp +++ b/netwerk/streamconv/src/nsStreamConverterService.cpp @@ -51,13 +51,12 @@ struct BFSState { // Adjacency list data class. struct SCTableData { - nsCStringKey *key; union _data { BFSState *state; nsCOMArray *edges; } data; - SCTableData(nsCStringKey* aKey) : key(aKey) { + SCTableData() { data.state = nullptr; } }; @@ -96,8 +95,7 @@ nsStreamConverterService::~nsStreamConverterService() { // Delete all the entries in the adjacency list static bool DeleteAdjacencyEntry(nsHashKey *aKey, void *aData, void* closure) { SCTableData *entry = (SCTableData*)aData; - NS_ASSERTION(entry->key && entry->data.edges, "malformed adjacency list entry"); - delete entry->key; + NS_ASSERTION(entry->data.edges, "malformed adjacency list entry"); delete entry->data.edges; delete entry; return true; @@ -183,30 +181,27 @@ nsStreamConverterService::AddAdjacency(const char *aContractID) { SCTableData *fromEdges = (SCTableData*)mAdjacencyList->Get(&fromKey); if (!fromEdges) { // There is no fromStr vertex, create one. - - nsCStringKey *newFromKey = new nsCStringKey(ToNewCString(fromStr), fromStr.Length(), nsCStringKey::OWN); - SCTableData *data = new SCTableData(newFromKey); + SCTableData *data = new SCTableData(); nsCOMArray* edgeArray = new nsCOMArray; data->data.edges = edgeArray; - mAdjacencyList->Put(newFromKey, data); + mAdjacencyList->Put(&fromKey, data); fromEdges = data; } nsCStringKey toKey(toStr); if (!mAdjacencyList->Get(&toKey)) { // There is no toStr vertex, create one. - nsCStringKey *newToKey = new nsCStringKey(ToNewCString(toStr), toStr.Length(), nsCStringKey::OWN); - SCTableData *data = new SCTableData(newToKey); + SCTableData *data = new SCTableData(); nsCOMArray* edgeArray = new nsCOMArray; data->data.edges = edgeArray; - mAdjacencyList->Put(newToKey, data); + mAdjacencyList->Put(&toKey, data); } // Now we know the FROM and TO types are represented as keys in the hashtable. // Let's "connect" the verticies, making an edge. - nsCOMPtr vertex = do_GetAtom(toStr); + nsCOMPtr vertex = do_GetAtom(toStr); if (!vertex) return NS_ERROR_OUT_OF_MEMORY; NS_ASSERTION(fromEdges, "something wrong in adjacency list construction");