Skip to content

Commit

Permalink
Make SerializedData into a POD struct.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 676124916
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Sep 18, 2024
1 parent 81c582a commit 5da098b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions rust/cpp_kernel/serialized_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ extern "C" struct SerializedData {
// Owns the memory, must be freed by Rust.
const uint8_t* data;
size_t len;

SerializedData(const uint8_t* data, size_t len) : data(data), len(len) {}
};

inline bool SerializeMsg(const google::protobuf::MessageLite* msg, SerializedData* out) {
Expand All @@ -53,7 +51,8 @@ inline bool SerializeMsg(const google::protobuf::MessageLite* msg, SerializedDat
if (!msg->SerializeWithCachedSizesToArray(bytes)) {
return false;
}
*out = SerializedData(bytes, len);
out->data = bytes;
out->len = len;
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion rust/test/cpp/interop/test_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extern "C" void MutateTestAllTypes(protobuf_unittest::TestAllTypes* msg) {

extern "C" SerializedData SerializeTestAllTypes(
const protobuf_unittest::TestAllTypes* msg) {
SerializedData data(nullptr, 0);
SerializedData data;
ABSL_CHECK(SerializeMsg(msg, &data));
return data;
}
Expand Down

0 comments on commit 5da098b

Please sign in to comment.