Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Unified Diff: dbus/message.cc

Issue 176693003: chromeos: Make dbus::MessageReader memory ownership explicit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove unnecessary reinterpret_cast Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dbus/message.h ('k') | dbus/message_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dbus/message.cc
diff --git a/dbus/message.cc b/dbus/message.cc
index 918b860090455ca4827741ae6733c9f1590e113d..eaf3c9bed9c4a101f4dfc9183dcade489519e8f4 100644
--- a/dbus/message.cc
+++ b/dbus/message.cc
@@ -807,7 +807,7 @@ bool MessageReader::PopVariant(MessageReader* sub_reader) {
return PopContainer(DBUS_TYPE_VARIANT, sub_reader);
}
-bool MessageReader::PopArrayOfBytes(uint8** bytes, size_t* length) {
+bool MessageReader::PopArrayOfBytes(const uint8** bytes, size_t* length) {
MessageReader array_reader(message_);
if (!PopArray(&array_reader))
return false;
@@ -829,9 +829,10 @@ bool MessageReader::PopArrayOfBytes(uint8** bytes, size_t* length) {
bool MessageReader::PopArrayOfStrings(
std::vector<std::string> *strings) {
+ strings->clear();
MessageReader array_reader(message_);
if (!PopArray(&array_reader))
- return false;
+ return false;
while (array_reader.HasMoreData()) {
std::string string;
if (!array_reader.PopString(&string))
@@ -843,9 +844,10 @@ bool MessageReader::PopArrayOfStrings(
bool MessageReader::PopArrayOfObjectPaths(
std::vector<ObjectPath> *object_paths) {
+ object_paths->clear();
MessageReader array_reader(message_);
if (!PopArray(&array_reader))
- return false;
+ return false;
while (array_reader.HasMoreData()) {
ObjectPath object_path;
if (!array_reader.PopObjectPath(&object_path))
@@ -858,9 +860,10 @@ bool MessageReader::PopArrayOfObjectPaths(
bool MessageReader::PopArrayOfBytesAsProto(
google::protobuf::MessageLite* protobuf) {
DCHECK(protobuf != NULL);
- char* serialized_buf = NULL;
+ const char* serialized_buf = NULL;
size_t buf_size = 0;
- if (!PopArrayOfBytes(reinterpret_cast<uint8**>(&serialized_buf), &buf_size)) {
+ if (!PopArrayOfBytes(
+ reinterpret_cast<const uint8**>(&serialized_buf), &buf_size)) {
LOG(ERROR) << "Error reading array of bytes";
return false;
}
« no previous file with comments | « dbus/message.h ('k') | dbus/message_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698