Bug 975823, part 5 - SCTableData only uses the edges case of its union. r=mcmanus

This commit is contained in:
Andrew McCreight 2014-03-19 16:57:48 -07:00
parent d3b6b10a50
commit 770c669fba

View File

@ -51,13 +51,10 @@ struct BFSState {
// Adjacency list data class.
struct SCTableData {
union _data {
BFSState *state;
nsCOMArray<nsIAtom> *edges;
} data;
nsCOMArray<nsIAtom> *edges;
SCTableData() {
data.state = nullptr;
SCTableData() : edges(nullptr)
{
}
};
@ -95,8 +92,8 @@ 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->data.edges, "malformed adjacency list entry");
delete entry->data.edges;
NS_ASSERTION(entry->edges, "malformed adjacency list entry");
delete entry->edges;
delete entry;
return true;
}
@ -185,7 +182,7 @@ nsStreamConverterService::AddAdjacency(const char *aContractID) {
nsCStringKey *newFromKey = new nsCStringKey(ToNewCString(fromStr), fromStr.Length(), nsCStringKey::OWN);
SCTableData *data = new SCTableData();
nsCOMArray<nsIAtom>* edgeArray = new nsCOMArray<nsIAtom>;
data->data.edges = edgeArray;
data->edges = edgeArray;
mAdjacencyList->Put(newFromKey, data);
fromEdges = data;
@ -197,7 +194,7 @@ nsStreamConverterService::AddAdjacency(const char *aContractID) {
nsCStringKey *newToKey = new nsCStringKey(ToNewCString(toStr), toStr.Length(), nsCStringKey::OWN);
SCTableData *data = new SCTableData();
nsCOMArray<nsIAtom>* edgeArray = new nsCOMArray<nsIAtom>;
data->data.edges = edgeArray;
data->edges = edgeArray;
mAdjacencyList->Put(newToKey, data);
}
@ -211,7 +208,7 @@ nsStreamConverterService::AddAdjacency(const char *aContractID) {
if (!fromEdges)
return NS_ERROR_FAILURE;
nsCOMArray<nsIAtom> *adjacencyList = fromEdges->data.edges;
nsCOMArray<nsIAtom> *adjacencyList = fromEdges->edges;
return adjacencyList->AppendObject(vertex) ? NS_OK : NS_ERROR_FAILURE;
}
@ -329,7 +326,7 @@ nsStreamConverterService::FindConverter(const char *aContractID, nsTArray<nsCStr
SCTableData *data2 = (SCTableData*)mAdjacencyList->Get(currentHead);
if (!data2) return NS_ERROR_FAILURE;
nsCOMArray<nsIAtom> *edges = data2->data.edges;
nsCOMArray<nsIAtom> *edges = data2->edges;
NS_ASSERTION(edges, "something went wrong with BFS strmconv algorithm");
if (!edges) return NS_ERROR_FAILURE;