OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/pickle.h" | 5 #include "base/pickle.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include <algorithm> // for max() | 9 #include <algorithm> // for max() |
10 | 10 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 } | 83 } |
84 | 84 |
85 bool PickleIterator::ReadInt64(int64* result) { | 85 bool PickleIterator::ReadInt64(int64* result) { |
86 return ReadBuiltinType(result); | 86 return ReadBuiltinType(result); |
87 } | 87 } |
88 | 88 |
89 bool PickleIterator::ReadUInt64(uint64* result) { | 89 bool PickleIterator::ReadUInt64(uint64* result) { |
90 return ReadBuiltinType(result); | 90 return ReadBuiltinType(result); |
91 } | 91 } |
92 | 92 |
| 93 bool PickleIterator::ReadFloat(float* result) { |
| 94 return ReadBuiltinType(result); |
| 95 } |
| 96 |
93 bool PickleIterator::ReadString(std::string* result) { | 97 bool PickleIterator::ReadString(std::string* result) { |
94 int len; | 98 int len; |
95 if (!ReadInt(&len)) | 99 if (!ReadInt(&len)) |
96 return false; | 100 return false; |
97 const char* read_from = GetReadPointerAndAdvance(len); | 101 const char* read_from = GetReadPointerAndAdvance(len); |
98 if (!read_from) | 102 if (!read_from) |
99 return false; | 103 return false; |
100 | 104 |
101 result->assign(read_from, len); | 105 result->assign(read_from, len); |
102 return true; | 106 return true; |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 return NULL; | 352 return NULL; |
349 | 353 |
350 const Header* hdr = reinterpret_cast<const Header*>(start); | 354 const Header* hdr = reinterpret_cast<const Header*>(start); |
351 const char* payload_base = start + header_size; | 355 const char* payload_base = start + header_size; |
352 const char* payload_end = payload_base + hdr->payload_size; | 356 const char* payload_end = payload_base + hdr->payload_size; |
353 if (payload_end < payload_base) | 357 if (payload_end < payload_base) |
354 return NULL; | 358 return NULL; |
355 | 359 |
356 return (payload_end > end) ? NULL : payload_end; | 360 return (payload_end > end) ? NULL : payload_end; |
357 } | 361 } |
OLD | NEW |