From 5da098b8b039e64711ee876810c4418ee8732f6b Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Wed, 18 Sep 2024 14:07:44 -0700 Subject: [PATCH] Make SerializedData into a POD struct. PiperOrigin-RevId: 676124916 --- rust/cpp_kernel/serialized_data.h | 5 ++--- rust/test/cpp/interop/test_utils.cc | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/rust/cpp_kernel/serialized_data.h b/rust/cpp_kernel/serialized_data.h index 48f310f9f6f80..60d6ab7be05f6 100644 --- a/rust/cpp_kernel/serialized_data.h +++ b/rust/cpp_kernel/serialized_data.h @@ -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) { @@ -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; } diff --git a/rust/test/cpp/interop/test_utils.cc b/rust/test/cpp/interop/test_utils.cc index beac499fb4a42..32e419ba200ad 100644 --- a/rust/test/cpp/interop/test_utils.cc +++ b/rust/test/cpp/interop/test_utils.cc @@ -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; }