mirror of
https://git.suyu.dev/suyu/breakpad.git
synced 2025-12-31 03:37:44 +01:00
Use stdint types everywhere
R=mark at https://breakpad.appspot.com/535002/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1121 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
parent
c02002a581
commit
aeffe1056f
117 changed files with 1385 additions and 1379 deletions
|
|
@ -49,7 +49,7 @@ class SimpleMapSerializer {
|
|||
static char* Serialize(const std::map<Key, Value> &stdmap,
|
||||
unsigned int* size = NULL) {
|
||||
unsigned int size_per_node =
|
||||
sizeof(u_int32_t) + sizeof(Key) + sizeof(Value);
|
||||
sizeof(uint32_t) + sizeof(Key) + sizeof(Value);
|
||||
unsigned int memsize = sizeof(int32_t) + size_per_node * stdmap.size();
|
||||
if (size) *size = memsize;
|
||||
|
||||
|
|
@ -58,12 +58,12 @@ class SimpleMapSerializer {
|
|||
char* address = mem;
|
||||
|
||||
// Writer the number of nodes:
|
||||
new (address) u_int32_t(static_cast<u_int32_t>(stdmap.size()));
|
||||
address += sizeof(u_int32_t);
|
||||
new (address) uint32_t(static_cast<uint32_t>(stdmap.size()));
|
||||
address += sizeof(uint32_t);
|
||||
|
||||
// Nodes' offset:
|
||||
u_int32_t* offsets = reinterpret_cast<u_int32_t*>(address);
|
||||
address += sizeof(u_int32_t) * stdmap.size();
|
||||
uint32_t* offsets = reinterpret_cast<uint32_t*>(address);
|
||||
address += sizeof(uint32_t) * stdmap.size();
|
||||
|
||||
// Keys:
|
||||
Key* keys = reinterpret_cast<Key*>(address);
|
||||
|
|
@ -95,16 +95,16 @@ class TestInvalidMap : public ::testing::Test {
|
|||
};
|
||||
|
||||
TEST_F(TestInvalidMap, TestNegativeNumberNodes) {
|
||||
memset(data, 0xff, sizeof(u_int32_t)); // Set the number of nodes = -1
|
||||
memset(data, 0xff, sizeof(uint32_t)); // Set the number of nodes = -1
|
||||
test_map = TestMap(data);
|
||||
ASSERT_FALSE(test_map.ValidateInMemoryStructure());
|
||||
}
|
||||
|
||||
TEST_F(TestInvalidMap, TestWrongOffsets) {
|
||||
u_int32_t* header = reinterpret_cast<u_int32_t*>(data);
|
||||
const u_int32_t kNumNodes = 2;
|
||||
const u_int32_t kHeaderOffset =
|
||||
sizeof(u_int32_t) + kNumNodes * (sizeof(u_int32_t) + sizeof(KeyType));
|
||||
uint32_t* header = reinterpret_cast<uint32_t*>(data);
|
||||
const uint32_t kNumNodes = 2;
|
||||
const uint32_t kHeaderOffset =
|
||||
sizeof(uint32_t) + kNumNodes * (sizeof(uint32_t) + sizeof(KeyType));
|
||||
|
||||
header[0] = kNumNodes;
|
||||
header[1] = kHeaderOffset + 3; // Wrong offset for first node
|
||||
|
|
@ -118,16 +118,16 @@ TEST_F(TestInvalidMap, TestWrongOffsets) {
|
|||
}
|
||||
|
||||
TEST_F(TestInvalidMap, TestUnSortedKeys) {
|
||||
u_int32_t* header = reinterpret_cast<u_int32_t*>(data);
|
||||
const u_int32_t kNumNodes = 2;
|
||||
const u_int32_t kHeaderOffset =
|
||||
sizeof(u_int32_t) + kNumNodes * (sizeof(u_int32_t) + sizeof(KeyType));
|
||||
uint32_t* header = reinterpret_cast<uint32_t*>(data);
|
||||
const uint32_t kNumNodes = 2;
|
||||
const uint32_t kHeaderOffset =
|
||||
sizeof(uint32_t) + kNumNodes * (sizeof(uint32_t) + sizeof(KeyType));
|
||||
header[0] = kNumNodes;
|
||||
header[1] = kHeaderOffset;
|
||||
header[2] = kHeaderOffset + sizeof(ValueType);
|
||||
|
||||
KeyType* keys = reinterpret_cast<KeyType*>(
|
||||
data + (kNumNodes + 1) * sizeof(u_int32_t));
|
||||
data + (kNumNodes + 1) * sizeof(uint32_t));
|
||||
// Set keys in non-increasing order.
|
||||
keys[0] = 10;
|
||||
keys[1] = 7;
|
||||
|
|
@ -171,10 +171,10 @@ class TestValidMap : public ::testing::Test {
|
|||
|
||||
// Set correct size of memory allocation for each test case.
|
||||
unsigned int size_per_node =
|
||||
sizeof(u_int32_t) + sizeof(KeyType) + sizeof(ValueType);
|
||||
sizeof(uint32_t) + sizeof(KeyType) + sizeof(ValueType);
|
||||
for (testcase = 0; testcase < kNumberTestCases; ++testcase) {
|
||||
correct_size[testcase] =
|
||||
sizeof(u_int32_t) + std_map[testcase].size() * size_per_node;
|
||||
sizeof(uint32_t) + std_map[testcase].size() * size_per_node;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue