summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/pickle.cc18
-rw-r--r--base/pickle.h4
2 files changed, 20 insertions, 2 deletions
diff --git a/base/pickle.cc b/base/pickle.cc
index 0be89c2..be76cf5 100644
--- a/base/pickle.cc
+++ b/base/pickle.cc
@@ -6,8 +6,8 @@
#include <stdlib.h>
+#include <algorithm> // for max()
#include <limits>
-#include <string>
//------------------------------------------------------------------------------
@@ -181,6 +181,20 @@ bool Pickle::ReadInt64(void** iter, int64* result) const {
return true;
}
+bool Pickle::ReadUInt64(void** iter, uint64* result) const {
+ DCHECK(iter);
+ if (!*iter)
+ *iter = const_cast<char*>(payload());
+
+ if (!IteratorHasRoomFor(*iter, sizeof(*result)))
+ return false;
+
+ memcpy(result, *iter, sizeof(*result));
+
+ UpdateIter(iter, sizeof(*result));
+ return true;
+}
+
bool Pickle::ReadIntPtr(void** iter, intptr_t* result) const {
DCHECK(iter);
if (!*iter)
@@ -355,7 +369,7 @@ char* Pickle::BeginWriteData(int length) {
}
void Pickle::TrimWriteData(int new_length) {
- DCHECK(variable_buffer_offset_ != 0);
+ DCHECK_NE(variable_buffer_offset_, 0);
// Fetch the the variable buffer size
int* cur_length = reinterpret_cast<int*>(
diff --git a/base/pickle.h b/base/pickle.h
index 9760483..850d4dc 100644
--- a/base/pickle.h
+++ b/base/pickle.h
@@ -70,6 +70,7 @@ class Pickle {
bool ReadSize(void** iter, size_t* result) const;
bool ReadUInt32(void** iter, uint32* result) const;
bool ReadInt64(void** iter, int64* result) const;
+ bool ReadUInt64(void** iter, uint64* result) const;
bool ReadIntPtr(void** iter, intptr_t* result) const;
bool ReadString(void** iter, std::string* result) const;
bool ReadWString(void** iter, std::wstring* result) const;
@@ -103,6 +104,9 @@ class Pickle {
bool WriteInt64(int64 value) {
return WriteBytes(&value, sizeof(value));
}
+ bool WriteUInt64(uint64 value) {
+ return WriteBytes(&value, sizeof(value));
+ }
bool WriteIntPtr(intptr_t value) {
return WriteBytes(&value, sizeof(value));
}