-
Notifications
You must be signed in to change notification settings - Fork 21
/
History.cc
53 lines (44 loc) · 1.39 KB
/
History.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// History.cc -- May 10, 2009
// by geohot
// part of "The Embedded Disassembler"
// released under GPLv3, see http://gplv3.fsf.org/
//
// I am a database of sorts
// modifiers_ maps Addresses to changelists they own
// modified_ maps Addresses to changelists that changed them
// I could map right to changelists themselves, but the numbers way is cleaner
#include "data.h"
#include "util.h"
using namespace eda;
void History::AddCommited(Changelist* cl) {
changelists_[cl->get_changelist_number()] = cl;
owned_[cl->get_owner()].push_back(cl->get_changelist_number());
ChangelistIterator it;
cl->get_first_change(&it);
do {
xrefs_[it->first].push_back(cl->get_changelist_number());
} while(cl->get_next_change(&it));
LOG(INFO) << "pushed " << cl->get_changelist_number();
}
Changelist* History::get_changelist(int changelist_number) {
map<int, Changelist*>::iterator it = changelists_.find(changelist_number);
if (it != changelists_.end())
return it->second;
else
return NULL;
}
// These need to turn into XML
vector<int>* History::get_owned(Address *a) {
map<Address*, vector<int> >::iterator it = owned_.find(a);
if (it != owned_.end())
return &it->second;
else
return NULL;
}
vector<int>* History::get_xrefs(Address *a) {
map<Address*, vector<int> >::iterator it = xrefs_.find(a);
if (it != xrefs_.end())
return &it->second;
else
return NULL;
}