Bug 975823, part 4 - SCTableData doesn't use its key field. r=mcmanus

This commit is contained in:
Andrew McCreight 2014-03-21 09:43:40 -07:00
parent 83858323d4
commit c570740f97

View File

@ -51,13 +51,12 @@ struct BFSState {
// Adjacency list data class.
struct SCTableData {
nsCStringKey *key;
union _data {
BFSState *state;
nsCOMArray<nsIAtom> *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<nsIAtom>* edgeArray = new nsCOMArray<nsIAtom>;
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<nsIAtom>* edgeArray = new nsCOMArray<nsIAtom>;
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<nsIAtom> vertex = do_GetAtom(toStr);
nsCOMPtr<nsIAtom> vertex = do_GetAtom(toStr);
if (!vertex) return NS_ERROR_OUT_OF_MEMORY;
NS_ASSERTION(fromEdges, "something wrong in adjacency list construction");