blob: 59dfa006636fe71e55ca9e94e2bc32e0b29dc850 (
plain)
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
54
55
56
57
58
59
60
|
/* Pedantic checking of DWARF files
Copyright (C) 2009,2010,2011 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
elfutils is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "addr-record.hh"
size_t
addr_record::find (uint64_t addr) const
{
size_t a = 0;
size_t b = size ();
while (a < b)
{
size_t i = (a + b) / 2;
uint64_t v = (*this)[i];
if (v > addr)
b = i;
else if (v < addr)
a = i + 1;
else
return i;
}
return a;
}
bool
addr_record::has_addr (uint64_t addr) const
{
if (begin () == end ()
|| addr < front ()
|| addr > back ())
return false;
const_iterator it = begin () + find (addr);
return it != end () && *it == addr;
}
void
addr_record::add (uint64_t addr)
{
iterator it = begin () + find (addr);
if (it == end () || *it != addr)
insert (it, addr);
}
|