* Get function containing the address @p a. */
| 183 | * Get function containing the address @p a. |
| 184 | */ |
| 185 | const retdec::common::Function* FunctionSet::getRange( |
| 186 | const retdec::common::Address& a) const |
| 187 | { |
| 188 | if (empty()) |
| 189 | { |
| 190 | return nullptr; |
| 191 | } |
| 192 | |
| 193 | auto pos = lower_bound(a); |
| 194 | |
| 195 | if (pos == end()) |
| 196 | { |
| 197 | auto last = rbegin(); |
| 198 | return (last->contains(a)) ? (&(*last)) : (nullptr); |
| 199 | } |
| 200 | |
| 201 | if (pos != begin() && pos->getStart() != a) |
| 202 | { |
| 203 | pos--; |
| 204 | } |
| 205 | |
| 206 | return pos->contains(a) ? &(*pos) : nullptr; |
| 207 | } |
| 208 | |
| 209 | } // namespace common |
| 210 | } // namespace retdec |