mirror of
https://github.com/yuzu-emu/breakpad.git
synced 2024-11-24 07:35:38 +01:00
Stylistic changes for RangeMap (#24). r=bryner
http://groups.google.com/group/airbag-dev/browse_thread/thread/97c378bd175ab7c0 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@25 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
parent
683c86e6c5
commit
d9fb68c3e0
@ -32,9 +32,6 @@
|
|||||||
namespace google_airbag {
|
namespace google_airbag {
|
||||||
|
|
||||||
|
|
||||||
using std::map;
|
|
||||||
|
|
||||||
|
|
||||||
template<typename AddressType, typename EntryType>
|
template<typename AddressType, typename EntryType>
|
||||||
class RangeMap {
|
class RangeMap {
|
||||||
public:
|
public:
|
||||||
@ -69,13 +66,12 @@ class RangeMap {
|
|||||||
// be stored, because RangeMap uses it as the key to the map.
|
// be stored, because RangeMap uses it as the key to the map.
|
||||||
const AddressType base_;
|
const AddressType base_;
|
||||||
|
|
||||||
// The entry, owned by the Range object.
|
// The entry corresponding to a range.
|
||||||
const EntryType entry_;
|
const EntryType entry_;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef map<AddressType, Range> AddressToRangeMap;
|
// Convenience types.
|
||||||
|
typedef std::map<AddressType, Range> AddressToRangeMap;
|
||||||
// Can't depend on implicit typenames in a template
|
|
||||||
typedef typename AddressToRangeMap::const_iterator const_iterator;
|
typedef typename AddressToRangeMap::const_iterator const_iterator;
|
||||||
typedef typename AddressToRangeMap::value_type value_type;
|
typedef typename AddressToRangeMap::value_type value_type;
|
||||||
|
|
||||||
@ -124,8 +120,7 @@ bool RangeMap<AddressType, EntryType>::StoreRange(const AddressType& base,
|
|||||||
|
|
||||||
template<typename AddressType, typename EntryType>
|
template<typename AddressType, typename EntryType>
|
||||||
bool RangeMap<AddressType, EntryType>::RetrieveRange(
|
bool RangeMap<AddressType, EntryType>::RetrieveRange(
|
||||||
const AddressType& address,
|
const AddressType &address, EntryType *entry) const {
|
||||||
EntryType* entry) const {
|
|
||||||
if (!entry)
|
if (!entry)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -17,9 +17,8 @@
|
|||||||
// Author: Mark Mentovai
|
// Author: Mark Mentovai
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <climits>
|
#include <climits>
|
||||||
|
#include <cstdio>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "processor/range_map.h"
|
#include "processor/range_map.h"
|
||||||
@ -33,7 +32,7 @@ using google_airbag::RangeMap;
|
|||||||
// allocated CountedObjects is maintained to help test memory management.
|
// allocated CountedObjects is maintained to help test memory management.
|
||||||
class CountedObject {
|
class CountedObject {
|
||||||
public:
|
public:
|
||||||
CountedObject(int id) : id_(id) { ++count_; }
|
explicit CountedObject(int id) : id_(id) { ++count_; }
|
||||||
CountedObject(const CountedObject &that) : id_(that.id_) { ++count_; }
|
CountedObject(const CountedObject &that) : id_(that.id_) { ++count_; }
|
||||||
~CountedObject() { --count_; }
|
~CountedObject() { --count_; }
|
||||||
|
|
||||||
@ -122,10 +121,10 @@ bool RetrieveTest(TestMap* range_map, const RangeTest* range_test) {
|
|||||||
AddressType low_offset = -1;
|
AddressType low_offset = -1;
|
||||||
AddressType high_offset = 1;
|
AddressType high_offset = 1;
|
||||||
if (range_test->size == 1) {
|
if (range_test->size == 1) {
|
||||||
if (!side) // when checking the low side,
|
if (!side) // When checking the low side,
|
||||||
high_offset = 0; // don't check one over the target
|
high_offset = 0; // don't check one over the target.
|
||||||
else // when checking the high side,
|
else // When checking the high side,
|
||||||
low_offset = 0; // don't check one under the target
|
low_offset = 0; // don't check one under the target.
|
||||||
}
|
}
|
||||||
|
|
||||||
for (AddressType offset = low_offset; offset <= high_offset; ++offset) {
|
for (AddressType offset = low_offset; offset <= high_offset; ++offset) {
|
||||||
@ -134,14 +133,14 @@ bool RetrieveTest(TestMap* range_map, const RangeTest* range_test) {
|
|||||||
(!side ? range_test->address :
|
(!side ? range_test->address :
|
||||||
range_test->address + range_test->size - 1);
|
range_test->address + range_test->size - 1);
|
||||||
|
|
||||||
bool expected_result = false; // correct for tests not stored
|
bool expected_result = false; // This is correct for tests not stored.
|
||||||
if (range_test->expect_storable) {
|
if (range_test->expect_storable) {
|
||||||
if (offset == 0) // when checking target,
|
if (offset == 0) // When checking the target address,
|
||||||
expected_result = true; // should always succeed
|
expected_result = true; // test should always succeed.
|
||||||
else if (offset == -1) // when checking one below target,
|
else if (offset == -1) // When checking one below the target,
|
||||||
expected_result = side; // should fail low and succeed high
|
expected_result = side; // should fail low and succeed high.
|
||||||
else // when checking one above target,
|
else // When checking one above the target,
|
||||||
expected_result = !side; // should succeed low and fail high
|
expected_result = !side; // should succeed low and fail high.
|
||||||
}
|
}
|
||||||
|
|
||||||
CountedObject object(-1);
|
CountedObject object(-1);
|
||||||
|
Loading…
Reference in New Issue
Block a user